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
61 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,120 points
57 views
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
• 9,660 points
53 views
+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
33 views
0 votes
2 answers

What do you mean by python scripting? What is a script and a module in python?

A scripting language is a programming language ...READ MORE

answered Mar 14 in Python by rajesh kumar
1,723 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
25 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
51 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
11 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.