0
Python - What's the error in this code?
Why list is not joined? Compiler tells me something as "string expected, int found" def func(x): for i in range(x): yield i**2 print(",".join(list(func(3))))
2 Respostas
+ 9
It's because you can't join a list of integers. The elements of the list have to be a string. Here is a fix:
print(",".join([str(i) for i in func(3)]))
+ 7
or
yield str(i**2)