Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104885

Re: Use of Lists, Tupples, or Sets in IF statement.

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Joel Goldstick <joel.goldstick@gmail.com>
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 <mailman.141.1458001918.12893.python-list@python.org> (permalink)
References <fcd34352-44d2-4912-b76c-7b3860c4fe1e@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de zU+hhWaC/l5zDeaklOG2MQ9WMn1I8rYQqQw8or0MZaPg==
Return-Path <joel.goldstick@gmail.com>
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&gt;': 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 <fcd34352-44d2-4912-b76c-7b3860c4fe1e@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:104885

Show key headers only | View raw


On Mon, Mar 14, 2016 at 8:26 PM, <jj0gen0info@gmail.com> 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://joelgoldstick.com/stats/birthdays>
http://cc-baseballstats.info/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Use of Lists, Tupples, or Sets in IF statement. jj0gen0info@gmail.com - 2016-03-14 17:26 -0700
  Re: Use of Lists, Tupples, or Sets in IF statement. Joel Goldstick <joel.goldstick@gmail.com> - 2016-03-14 20:31 -0400
  Re: Use of Lists, Tupples, or Sets in IF statement. Chris Angelico <rosuav@gmail.com> - 2016-03-15 11:33 +1100
  Re: Use of Lists, Tupples, or Sets in IF statement. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 00:38 +0000
    Re: Use of Lists, Tupples, or Sets in IF statement. jj0gen0info@gmail.com - 2016-03-14 18:32 -0700
  Re: Use of Lists, Tupples, or Sets in IF statement. jj0gen0info@gmail.com - 2016-03-14 18:24 -0700
  Re: Use of Lists, Tupples, or Sets in IF statement. Steven D'Aprano <steve@pearwood.info> - 2016-03-15 13:10 +1100
  Re: Use of Lists, Tupples, or Sets in IF statement. Rustom Mody <rustompmody@gmail.com> - 2016-03-14 23:30 -0700
    Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement. Peter Otten <__peter__@web.de> - 2016-03-15 09:29 +0100
      Re: Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement. Rustom Mody <rustompmody@gmail.com> - 2016-03-15 04:08 -0700
        Re: Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement. Peter Otten <__peter__@web.de> - 2016-03-15 18:34 +0100
          Re: Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement. Rustom Mody <rustompmody@gmail.com> - 2016-03-15 19:54 -0700

csiph-web