Loops question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Loops question

tj=55 while tj>=0: print("tj") tj=tj-1 Output is tj 56 times After that print(tj) Output is -1 why ❓

29th May 2018, 12:31 PM
Tejas Tripathi
Tejas Tripathi - avatar
1 Answer
+ 2
replace the tj>=0 with tj>0 to se if it outputs 0 instead of -1 its outpiting -1 because since its set to stop when it hits 0, when it hits 0 it, it runs once more setting it to -1.
29th May 2018, 12:36 PM
Henry Arch
Henry Arch - avatar