x=(y for y in range(100) if y%2==0 and y%5==0)
print(x)
This is giving output like -
<generator object <genexpr> at 0x00000222B1C3CC80>
x=(y for y in range(100) if y%2==0 and y%5==0)
print(x)
This is giving output like -
<generator object <genexpr> at 0x00000222B1C3CC80>
Here is what you can do
x=tuple(y for y in range(100) if y%2==0 and y%5==0)
Tuple comprehension is not a thing. Check this SO post to understand why.
Do this instead:
x = tuple(y for y in range(100) if y%2==0 and y%5==0)
This uses the tuple()
constructor to make a tuple from the generator object. You can use this constructor to make a tuple from elements yielded by an iterator or iterable object. So, this code works because generator objects can be used as iterators.
You can use tuple()
function to cast it.
x = (y for y in range(100) if y % 2 == 0 and y % 5 == 0)
print(tuple(x))
# (0, 10, 20, 30, 40, 50, 60, 70, 80, 90)