What is causing this error?:
int() argument must be a string, a bytes-like object or a number, not 'generator'
Context:
I'm trying to append the yield of a generator. Here is a minimal reproducible example:
def my_func(values, n):
def my_gen():
for x in values:
yield x
collections = []
for i in range(0, n):
collections.append(int(my_gen()))
return collections
x = my_func([1, 2, 3, 4, 5], 2)
print(x)
Expected Output:
[1, 2]