[Tutor] Why is this not an error?

Steve N smnordby at yahoo.com
Sun Mar 20 14:46:24 CET 2005


This code runs, but it seems to me it should generate
a syntax error.  Can someone explain what's going on?

x = [1,2,3,4]
z = 4
if z in x:
    print 'found:', z
for i in x:
    print 'in the loop with', i
else:
    print 'not found:', z

>>> 
found: 4
in the loop with 1
in the loop with 2
in the loop with 3
in the loop with 4
not found: 4
>>> 

--
Steve



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more. 
http://info.mail.yahoo.com/mail_250


More information about the Tutor mailing list