+ 2

Help

How do I know when to use do...whiles vs using a while loop?

12th Dec 2017, 8:45 AM
John Estrada
John Estrada - avatar
4 Answers
+ 7
Python does not have a do .. while. It just has a while.
12th Dec 2017, 8:58 AM
Eric Blinkidu
Eric Blinkidu - avatar
+ 1
do...while is just like a while loop, both run until the the condition mets false Only difference: do...while allows to run once even if the condition is false whereas while loop doesn't
12th Dec 2017, 9:07 AM
#RahulVerma
#RahulVerma - avatar
+ 1
You can effectively get a do-while in python by using: while True: ... code here ... if someCondtionIsTrue: break
12th Dec 2017, 9:28 AM
ChaoticDawg
ChaoticDawg - avatar
0
the difference is that you use "do while" if want the code to run one time at least Even if the condition is not met .
12th Dec 2017, 8:52 AM
Ahmed Mohammed Ahmed Khodary
Ahmed Mohammed Ahmed Khodary - avatar