"for" with "else"?
Invalid User
user at invalid.domain
Thu Sep 25 09:31:08 EDT 2003
While trying to print a none empty list, I accidentaly put an "else"
statement with a "for" instead of "if". Here is what I had:
if ( len(mylist)> 0) :
for x,y in mylist:
print x,y
else:
print "Empty list"
which was supposed to be:
if ( len(mylist)> 0) :
for x,y in mylist:
print x,y
else:
print "Empty list"
Is this to be expected?
(python 2.2.2)
++++++++++++++++++++++++++++++=
>>> for x in range(5):
... print x*x
... else:
... print "done"
...
0
1
4
9
16
done
++++++++++++++++++++++++++++++=
More information about the Python-list
mailing list