+ 1

How does this code work

I am asking about line 3 in this code I mean there's no command in it no print or any thing so how does it work and if you have more examples like that please tell me i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue if i == 5: print("Breaking") break print(i) print("Finished")

17th Dec 2019, 1:21 PM
Pattern
Pattern - avatar
1 Risposta
+ 3
It is assignment , the value(i+1) is being assigned to the variable i , simply put , the value of i is increasing by 1. It is the same as i = 0 , where you are assigning the value (0) to variable i. The value of i increases by 1 each time the loop re-iterates , and the loop stops when i is 5.
17th Dec 2019, 1:29 PM
Aatif Fraz
Aatif Fraz - avatar