Do-while loop in Python

0 votes
How do we create a do-while loop in Python
May 11, 2018 in Python by kaalabilli
• 1,090 points
115 views

1 answer to this question.

0 votes

Python does not have a do-while construct. 

If you wish to emulate a do-while loop, you must make sure that your loop body is execute atleast once, so try this out - 

condition = True
while condition:
    # loop body here
    condition = test_loop_condition()
...
answered May 11, 2018 by Hamartia's Mask
• 1,580 points

Related Questions In Python

0 votes
1 answer

Why there is no do while loop in python

There is no do...while loop because there ...READ MORE

answered Aug 6, 2018 in Python by Priyaj
• 56,900 points
134 views
0 votes
1 answer
0 votes
0 answers
0 votes
1 answer

Empty while loop in Python

while file.readline().startswith("#"):     pass The pass statement does nothing. It ...READ MORE

answered Dec 5, 2018 in Python by SDeb
• 13,160 points
237 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 276 views
+4 votes
6 answers
0 votes
1 answer

Increment operators in Python

Python has no unary operators. So use ...READ MORE

answered May 11, 2018 in Python by Hamartia's Mask
• 1,580 points
112 views
0 votes
1 answer

Binary numbers in python

>>> 0b1011 11 READ MORE

answered Jun 6, 2018 in Python by Hamartia's Mask
• 1,580 points
26 views