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

jj0gen0info at gmail.com jj0gen0info at gmail.com
Mon Mar 14 20:26:43 EDT 2016


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')


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /