+ 1

Can you please explain why it prints this way

I wrote a code trying to print fibonacci numbers it worked but now i want to separate the numbers with a comma and print it all on the same line can you please explain why this doesn't work Thank you num=eval(input("how many Fibonacci numbers do you want? ")) a=0 b=1 print(a,b, sep=",") for i in range(num): c = a + b a = b b = c print(c, sep=",") OUTPUT with 12 how many Fibonacci numbers do you want? 12 0,1 1 2 3 5 8 13 21 34 55 89 144 233

4th Mar 2020, 4:05 AM
Ayanfe
Ayanfe - avatar
2 Respostas
+ 3
You should print value of b variable instead of c variable. print(b, sep=", ") Try this.
4th Mar 2020, 4:09 AM
ƬIMΛ
ƬIMΛ - avatar
0
I tried print(b, sep=", ") but it doesnt still work
4th Mar 2020, 8:47 PM
Ayanfe
Ayanfe - avatar