Squarepoint Capital Interview Question

In Python, what is the difference between a generator expression and a list comprehension?

Interview Answer

Anonymous

Dec 26, 2016

Example of list comprehension: [x*2 for x in range(10) if x%2] Example of generator expression: (x*2 for x in range(10) if x%2)

2