HomePython Page 3 - Python 101 (part 3): A Twist In The Tail
Making Friends And Influencing People - Python
Find out more about adding flow control to your Python programswith the "for" and "while" loops, see how the range() function can be usedto generate number ranges, and learn all about list objects. And bring anold flame along for the ride.
while the "in" and "not in" operators can be used to test for the presenceof a particular element in a list. A match returns 1 (true), while afailure returns 0 (false).
>>> superheroes
['Spiderman', 'Superman', 'Human Torch', 'Batman']
>>> "batman" in superheroes
0
>>> "Batman" in superheroes
1
>>> "Batma" in superheroes
0
>>> "Incredible Hulk" in superheroes
0
>>> "Incredible Hulk" not in superheroes
1
>>>