0

k = 5 while k <= 100: print("k") k= k+5

why this code just gave me endless ks

2nd Aug 2018, 10:18 AM
mugalu
9 ответов
+ 2
the last line should indeted to put it in the loop: while .. print ... k = k+5
2nd Aug 2018, 10:19 AM
davy hermans
davy hermans - avatar
+ 2
the statement k = k + 5 is not on the body of the loop possibly. indent it to get it in line with the print statement
2nd Aug 2018, 10:19 AM
Vedant Bang
Vedant Bang - avatar
+ 2
mugalu then it should be print(k) k = k + 5
2nd Aug 2018, 12:26 PM
Vedant Bang
Vedant Bang - avatar
+ 1
thanks alot now i got it
4th Aug 2018, 8:32 PM
mugalu
0
but i din't expect my out put to be the k. i thought it would be 5 10 15 20 25 30 35 40 up to 100 Vedant Bang
2nd Aug 2018, 11:19 AM
mugalu
0
mugalu Then you should write : print(k)
2nd Aug 2018, 11:36 AM
Alexandru Turculet
Alexandru Turculet - avatar
0
Hey mugalu; You mustnt do:"k=k+5" do:"k+=5"
2nd Aug 2018, 12:10 PM
Sousou
Sousou - avatar
0
Try; k=5 while k >= 100: print(k) k+=5
2nd Aug 2018, 12:22 PM
Sousou
Sousou - avatar
0
Sousou He is programming in python
2nd Aug 2018, 12:27 PM
Alexandru Turculet
Alexandru Turculet - avatar