8th Sep 2021, 3:42 PM
KᗩᗩTᑌᗷᗩᗷᑌ
5 Respostas
+ 4
you write increasement before if else statement in first code In second code you write after if else They work like x=1 while x <= 13: x+=1 # x is 2 now ,add 1 to initial value of x if.... Second code x=1 while x <= 13: if x%2==0: #x is still 1 print(str(x) + " is even number") else: print(str(x) + " is odd number") x+=1 #now x is 2 and loop till x=13
8th Sep 2021, 4:01 PM
Myo Thuzar
Myo Thuzar - avatar
+ 2
KᗩᗩTᑌᗷᗩᗷᑌ In first case you are first incrementing then checking condition so how could be result same?
8th Sep 2021, 3:57 PM
AÍąJ
AÍąJ - avatar
+ 2
KᗩᗩTᑌᗷᗩᗷᑌ In first case x will be 2 on 1st iteration. In second case x will be remain same means 1 on 1st iteration. So obviously output would be different.
8th Sep 2021, 3:59 PM
AÍąJ
AÍąJ - avatar
+ 2
Thanks , i understood now
8th Sep 2021, 4:07 PM
KᗩᗩTᑌᗷᗩᗷᑌ
+ 1
I did it by mistake , but i changed the code now. Plzz check it.
8th Sep 2021, 3:48 PM
KᗩᗩTᑌᗷᗩᗷᑌ