[Tutor] Why is this not an error?
Kent Johnson
kent37 at tds.net
Sun Mar 20 23:04:59 CET 2005
Hameed U. Khan wrote:
> This else is the part of the for loop. And the statements in this else will be
> executed if your for loop will complete all of its iterations. if you want
> this else with 'if' statement then remove the for loop.
Or if you want the for loop to be part of the if then indent the for:
if z in x:
print 'found:', z
for i in x:
print 'in the loop with', i
else:
print 'not found:', z
Remember - indentation is syntactically significant in Python!
More information about the Tutor
mailing list