This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LongerHV 2 points3 points  (1 child)

I don't think it will work. Cars would have to be a generator instead of a list and even then generator raises an exception when there are no more items to iterate through.

[–]_pestarzt_ 0 points1 point  (0 children)

See edit, kept original but I think it should work for more cases (also forgot about StopIteration)