Generators : Generator Function « Buildin Function « Python






Generators

Generators

def reverse(data):
    for index in range(len(data)-1, -1, -1):
        yield data[index]
  
for char in reverse('golf'):
     print char


           
       








Related examples in the same category

1.A generator function: creates its objects on the fly.A generator function: creates its objects on the fly.
2.Generator ExpressionsGenerator Expressions