Last answered:

25 Jan 2023

Posted on:

25 Jan 2023


Resolved: Question 7: Where is the i?


I am a little confused about this lines

for i in range (n)
    fib_numb.append (a)
    a,b = b, a+a

Where is the 2. i in this? I thought i has to be in the next line used in a for loop to work. Why does it work now without a second line with i?
Because of my understanding, I had quite a struggle to solve the question quickly.

Thanks for the help in advance!

1 answers ( 1 marked as helpful)
Posted on:

25 Jan 2023


Hey Daria,

Thank you for reaching out!

In this case, i serves as a counter which counts the number of iterations we have to perform. Examine the following code:
Here, I've added a print-function including the iterator i to illustrate how its value changes.

Hope this helps!

Kind regards,
365 Hristina

Submit an answer