+ 1

Basic difference between these two codes are....plz help. Upper one is written by me and lower i copied ..

n = 1 while n <=10: print(n) i = i + 1 print("finished") i = 1 while i <=5: print(i) i = i + 1 print("Finished!")

30th Mar 2018, 9:40 AM
ALBERT SAURAV
ALBERT SAURAV - avatar
2 odpowiedzi
+ 12
There's a little problem in the upper code... See the 4th line i = i + 1 ★ Instead of "i" it should be "n". Else the code will result in an infinite loop. Corrected Code - n = 1 while n<=10: print(n) n = n + 1 print("finished")
30th Mar 2018, 9:51 AM
Nikhil
Nikhil - avatar
+ 1
thanks.... brother.....
30th Mar 2018, 9:52 AM
ALBERT SAURAV
ALBERT SAURAV - avatar