0

Can anyone plz elaborate how this code works line by line or just generalise the 6th line

Please write the 6th in general form https://code.sololearn.com/cfGvTBet5HfX/?ref=app num = int(input()) a = 0 b = 1 while a <= num: #10 print(a) a,b = b,a+b

20th Sep 2021, 12:10 PM
Bald Bear
Bald Bear - avatar
4 ответов
+ 4
Line 6 could be rewritten like this: c = a + b a = b b = c
20th Sep 2021, 12:16 PM
Lisa
Lisa - avatar
+ 3
Line 6 as it is saves us one variable (c) It assigns the inital b to a and the initial a+b to b in the same line
20th Sep 2021, 12:22 PM
Lisa
Lisa - avatar
+ 1
Hey Lisa i really appreciate your help and its working but i failed to understand the reason behind it.It'd would be really nice of u to please explain the changes. :(:
20th Sep 2021, 12:20 PM
Bald Bear
Bald Bear - avatar
+ 1
Nevermind i understood and really thanks for the help
20th Sep 2021, 12:21 PM
Bald Bear
Bald Bear - avatar