0

Why is this code giving an error?(ignoring indentation)

def func(x): for i in range(x): yield i**2 print(",".join(list(func(3))))

2nd Jul 2021, 10:45 AM
Meghraj
Meghraj - avatar
3 Antworten
0
just switch the yield statement to make it a string output. cant join numbers, but you can join strings https://code.sololearn.com/cJl7YMIgbrSp/?ref=app
2nd Jul 2021, 10:49 AM
Slick
Slick - avatar
+ 1
newstring = '-'.join(list) listback = newstring.split('-')
2nd Jul 2021, 12:53 PM
Slick
Slick - avatar
0
can we also convert the list to string after generation?
2nd Jul 2021, 12:44 PM
Meghraj
Meghraj - avatar