question about for cycle
fdu.xiaojf at gmail.com
fdu.xiaojf at gmail.com
Sat Sep 29 06:04:06 EDT 2007
Hi all,
I have the following code:
for i in generator_a: # the first "for" cycle
for j in generator_b:
if something_happen:
# do something here ..., I want the outer cycle to break
break
What should I do if I want the outer "for" cycle to continue or break ? If I
put a "continue" or "break" in the inner cycle, it has no effect on the outer
cycle.
And I have another question. Which is the most efficient way to check if there
are duplicate items in a list ? The items in the list may cannot be hashed, so
set() may not work on the list.
Regards,
More information about the Python-list
mailing list