+ 1

Why there is no "do while" loop in python?

6th Mar 2019, 3:25 PM
Nikhil Yella
Nikhil Yella - avatar
2 Answers
+ 3
Because the designer didn't implement it. I guess it's for the sake of simplicity; for example increment operators are also not available. Instead of something like: do cin >> inp; while(cin!=whatever); ... you would write: while True: int = input() if condition: break
6th Mar 2019, 5:47 PM
HonFu
HonFu - avatar
+ 1
x=0 while x<100: print(f'To infinity & beyond. {x}') x+=1 This is another example of how to break a whole loop in python. It is essentially the same example HonFu gave
6th Mar 2019, 6:57 PM
Steven M
Steven M - avatar