5 ms·
The parens are required. What you've written raises a SyntaxError. You can omit them in the generator expression if it's being passed directly as the only para
by dmg8 14y ago
The parens are required. What you've written raises a SyntaxError.
You can omit them in the generator expression if it's being passed directly as the only parameter to a function:
halve_evens_only = list(i/2 for i in nums if i % 2 != 0)