There should be 2 also in output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

There should be 2 also in output?

I=1 while I<=5 print(i) I=I+3 print (end)

11th Feb 2017, 2:11 PM
Prashant Singh
Prashant Singh - avatar
2 Answers
+ 1
your question gives us i as an initial value of 1 ok and then tells us to print i to the screen while i<=5 but we should add 3 to i before it prints to the screen so i + 3=4 for the answer
11th Feb 2017, 3:06 PM
EMMANUEL NUOTAH TUONUO DERY
EMMANUEL NUOTAH TUONUO DERY - avatar
0
I'm gonna rewrite your code but "with" indentation: I=1 while I<=5: print(I) I=I+3 print("end") in this case you'll have 2 outputs; the first one being I and the second being "end".. however if you want to get "end" only once when the program is done, remove the print from the loop: I=1 while I<=5: print(I) I=I+3 print("end")
12th Feb 2017, 8:46 AM
ramzi
ramzi - avatar