Quote (ROM @ Oct 20 2015 05:45am)
You need to emulate a do while loop using a Boolean variable. You should avoid using breaks unless you are in switch selection statement. It works but its sloppy.
A Boolean variable is a variable that only hold two values, true or false.
This is not formatted right but,
Boolean condition;
While (condition)
{
Your code
Condition = test_condition ();
}
You will nest your entire program in the while loop and test condition will return a true to continue or a false to exit.
Python doesn't have do while technically and it doesn't have case-switch either, but logically things should work out okay.
With the way Python and most languages should work, 0 will come back is false, so you can reference anything to 0 and check with bool() to see if False.
Code
>>> a = 0
>>> b = 1
>>> bool(a)
False
>>> bool(b)
True
>>>
I'm not sure how far you are with Python, if you're allowed to use functions or not, but generally things start to make more sense with the introduction of those.
Since I believe that you're wanting to have your whole program looping, having your code separated into a function or functions and setting these up in the loop while probably give you what you need.
Code
def main():
# all your code
# prompt for input
# calculate
# ask if you want to continue or make separate continue() function
def continue():
# ask if want to continue
# return True or False
while continue():
main()
# exits when continue() == False