Use of Lists, Tupples, or Sets in IF statement.
Mark Lawrence
breamoreboy at yahoo.co.uk
Mon Mar 14 20:38:13 EDT 2016
On 15/03/2016 00:26, 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.
>
It's actually "tuple", but what the heck :)
> E.g.
>
> x = "apple"
>
> x-list = ["apple", "banana", "peach"]
>
> If x == x-list:
> print('Comparison is True')
> else:
> print('Comparison is False')
>
if x in x-list:
...
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list