I want to define a generator from a list that will output the elements one at a time, then use this generator object in an appropriate manner.
a = ["Hello", "world", "!"]
b = (x for x in a)
c = next(b, None)
while c != None:
print c,
c = next(b, None)
Is there anything wrong or improvable with the while
approach here? Is there a way to avoid having to assign 'c' before the loop?
Thanks!