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

Joel Goldstick joel.goldstick at gmail.com
Mon Mar 14 20:31:55 EDT 2016


On Mon, Mar 14, 2016 at 8:26 PM, <jj0gen0info at 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/



More information about the Python-list mailing list