Let numbers be a list of natural numbers. Consider the two ways of defining odd:
A.
odd = (n for n in numbers if n % 2 == 1)
B.
odd = [n for n in numbers if n % 2 == 1]
In which case odd is a generator and in which it's a list?
Let numbers be a list of natural numbers. Consider the two ways of defining odd:
A.
odd = (n for n in numbers if n % 2 == 1)
B.
odd = [n for n in numbers if n % 2 == 1]
In which case odd is a generator and in which it's a list?
Create a free account to access the full topic