Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: Use of Lists, Tupples, or Sets in IF statement. Date: Mon, 14 Mar 2016 20:31:55 -0400 Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de zU+hhWaC/l5zDeaklOG2MQ9WMn1I8rYQqQw8or0MZaPg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'matches': 0.07; 'cc:addr:python-list': 0.09; 'python': 0.10; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'element': 0.18; 'email addr:gmail.com>': 0.18; 'variable': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'header:In- Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; '14,': 0.27; 'url:mailman': 0.30; 'e.g.': 0.30; 'skip:[ 10': 0.31; 'url:python': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'set.': 0.35; 'list,': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'received:209': 0.38; 'received:209.85.214': 0.39; 'url:mail': 0.40; 'mar': 0.65; 'url:info': 0.71; 'subject:Sets': 0.84; 'joel': 0.91; 'subject:Lists': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=Bxi8NmZBPBIt3Rd7UJWy7G3xlHQiRbQ1/CmCeg1NePs=; b=qbrSUmy0QfWXRkoA7gnthcbqLHs9aGtL9OpRiDCU7Qdl9LtDlFltJ3QzngFmNIzCDG Syo7A4IFauAREpcOYCNoS9UtjZwDpBSIRWVgNfiOI60i+YWjTVYKg8gjVyU4aG1m/RiO rieP5T2ZBaAhSmHeiZRR/PGYIj+X7fgkfowsQCar5EtlQAnZw5y/NQKWI81uLxHYi0sB WzGcdr5yMoSmJmancCADG6Ka0bVZevwanrYW37QhDuTlp12pyR4RNpT4SdhVeN1vSOIT IW+ddUtkDIDAbyn4/8jBSZOpyalt94Z+JHEVy4lrmYFUu7TRt0rDaFrz4BkNeKawXUM/ t0Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=Bxi8NmZBPBIt3Rd7UJWy7G3xlHQiRbQ1/CmCeg1NePs=; b=WLgLD7tTuOLKU3QPaQ7VlKBaOts/h3nAgIG/HVkaABAyzT2CAObpT+BvYGr3A3Jwv2 zvPe0p9G8rH5BERPcmPmCs8jNCklxkqZqaabB+RbunuzRzNSAkohmDU1eanpYffOjGXe eD+i5BHNJDsG2P1zIqOCGY+AKUqYjVy8vDlyW8g2M3ystOmKGs8fvhNB4eDQiwTeWDjm f4SIvOMSIIa9TOKhTp8MMC1UNOdu03wilEs5a7UgICBevojg11XhOwdIcIJpc6Lc6ib7 XLFqvpyEluO+2uS1mX6WuED2Ey6/YVlhaqfA7JRJQRlx92EmOPcLBTiHMybv1AjiKDMj POmw== X-Gm-Message-State: AD7BkJLV9OtAVEytZGZ3hm8BlGiMu7MGBVqPsX4I1zUhmTxcMfEptSijK2vcn0ufNUJxAt8D9wO3ytSDNy1FRQ== X-Received: by 10.182.107.137 with SMTP id hc9mr15289219obb.74.1458001915262; Mon, 14 Mar 2016 17:31:55 -0700 (PDT) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104885 On Mon, Mar 14, 2016 at 8:26 PM, wrote: > In Python is it possible to comparison-equate a variable to a List, > Tupple, or Set and have it return True if the contents of the variable > matches an element in the List, Tupple, or Set. > > E.g. > > x = "apple" > > x-list = ["apple", "banana", "peach"] > > If x == x-list: > print('Comparison is True') > else: > print('Comparison is False') > > -- > https://mail.python.org/mailman/listinfo/python-list > if x in x-list -- Joel Goldstick http://joelgoldstick.com/ http://cc-baseballstats.info/