0

Is while 1==1 equal to while 2==2 and so on ?do all while x==x indicate the same thing?(x is integer)

22nd Sep 2018, 12:40 AM
partha
partha - avatar
2 Answers
+ 7
Yes. It's common to just say while True: [do stuff] if [something]: break
22nd Sep 2018, 1:35 AM
David Ashton
David Ashton - avatar
+ 3
Any integer compared with itself will be evaluated as True, as such passing that expression as loop condition will turn the loop into an infinite one, as the expression always evaluates to True (cmiiw)
22nd Sep 2018, 1:21 AM
Ipang