0

Pls what’s wrong with this?

e=3 while True: e=e+2 if e<4: print('yes') continue if e>4: print(e) print('finished')

15th Jul 2020, 3:05 PM
Elijah Oduyemi
Elijah Oduyemi - avatar
7 Answers
+ 2
It's printing 'e' after adding 2 on it. It will be executed repeatedly because the condition of while loop will always remain true. And 'e' is assigned 3 here and after adding 2 only one time it will become 5 so, the first if statement won't run because 4 will never get the chance to be greater than 'e'... In the next if statement 'e' will be always be greater than 4 because it became 5 after adding 2 only one time. So, it will keep printing 'e' after adding 2 on it.
15th Jul 2020, 3:15 PM
Arctic Fox
Arctic Fox - avatar
0
Elijah Oduyemi It's an infinite loop.what output do you want .
15th Jul 2020, 3:08 PM
uday kiran
uday kiran - avatar
0
uday kiran to print e
15th Jul 2020, 3:09 PM
Elijah Oduyemi
Elijah Oduyemi - avatar
0
value in e
15th Jul 2020, 3:12 PM
Elijah Oduyemi
Elijah Oduyemi - avatar
0
Nothing wrong in your code.it is printing value in e for infinite times
15th Jul 2020, 3:14 PM
uday kiran
uday kiran - avatar
0
okayy thank you
15th Jul 2020, 3:14 PM
Elijah Oduyemi
Elijah Oduyemi - avatar
15th Jul 2020, 3:18 PM
Elijah Oduyemi
Elijah Oduyemi - avatar