0
Explain the difference In Infinte Loops Code
Code 1 i = 0 while 1==1: i = i + 1 print(i) if i >= 5: print("Breaking") break print("Finished") Code 2 i = 0 while 1==1: print(i) i = i + 1 if i >= 5: print("Breaking") break print("Finished")
2 Réponses
+ 3
Your loops are not infinite, as you have a reachable base case wich break the loop when i >= 5 ^^
Anayway, the only difference between your two snippets is the print function, wich occurs respectively after or before incrementing i ;P
+ 1
There is code playground ,use it