0
Why do I get 1 as output in case of if while I get 1,2,3,4,5 in case of while
5 Respuestas
+ 2
If is a conditional statement. It runs the code only once while while is a loop and it would keep running till the condition is met.
+ 1
Because you didn't print i after increasing it
0
But why do I get 1 why don't I get 2 ( i + 1 == 2)
0
Ifham Khwaja because you print the value of i before increasing its value.
If you have to print 2 use print statement after increasing the value of i....
i=1
if i<=5:
i+=1
print(i)
print('Finished!')
0
Thanks a lot guys