+ 2
fibonacci never attaining output
a = 0 b = 1 while a < 21: a # so we know what variable we are focusing on b, a + b, b else: while a > 21: print(a) a, b = b + a, b #the computer is lying. why doesn't it count over 20?
2 Antworten
+ 4
a_s_a_p
First, a computer can not lie, and second, it's better to learn the basics first. For learning the basics please take a look at some Tutorials like sololearn. You will find many more Tutorials in the web.
https://code.sololearn.com/crmosLd7oU6t/?ref=app
Take a look at this code for compute the fibonacci series.
Regards kiuziu
+ 3
The computer is not lying. You've created a while loop which keeps looping while a < 21 but you don't change the value of a. If the code ever got past your first while loop, it would throw an error because you don't use an else statement with a while loop.