Pop quiz. What does this print? gen = (x ** 2 for x in range(5)) print(sum(gen)) print(sum(gen)) If you said 30 and 30, you just learned something important. The actual output: 30 0 Generator Expressions Are Single-Use A generator expression with pa...
Markdown supported · ⌘↵ to post
No responses yet.