[Tutor] membership

alan.gauld@bt.com alan.gauld@bt.com
Wed, 5 Dec 2001 11:58:30 -0000


> does the membership (in) function work for lists and
> strings like it does for Tuples?

Yes, it works for all sequences including lists and strings
Very useful for input validation:

if response in "yY": doSomething()
elif response in "Nn": doAnother()
else: print 'Must respond Y/N"


>  is the there a got line X function in Python for
> creating loops?

I assume you mean GOTO line X?
The answer is NO. Most modern languages denigrate the 
use of GOTO, loops in Python are implemented using

for <item> in <sequence>:

OR 

while <condition>:

These can be modified using the break and continue statements.
By combining these there is no need for a GOTO and the code 
remains maintainable for longer!

>  How do I unsubscribe from the daily digest? TIA

Go to the tutor web page on python.org and chamge your 
settings

Alan g