Pregunta de entrevista de Squarepoint Capital

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

Respuesta de la entrevista

Anónimo

26 dic 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