+ 1

how will this give 3 as output??

how many numbers does this code print?? i = 5 while True: print(i) i = i - 1 if i <= 2: break

9th Sep 2016, 7:17 AM
Abhi Ram
Abhi Ram - avatar
2 Answers
+ 3
3 values from 5 to 3. After printing 3, i is decremented (=2), the condition in the if is true so we enter it, and then the break makes us exit the loop.
9th Sep 2016, 8:44 AM
Zen
Zen - avatar
+ 1
3
31st Aug 2018, 2:36 AM
Ammar Muhammad Abubakar
Ammar Muhammad Abubakar - avatar