I would like to add the option of allowing the user to terminate the following program with a string command (such as 'exit' or 'quit'), but since the user input accepts and processes integers only, I can see no way to add that string exit command. For the moment, I've figured out how to add an integer exit command ("00").
(As long as I'm asking this question, my first on this forum, technical question: How do I copy-and-past code so that it looks exactly as it appears on my Idle compiler screen? I wanted to indent the body of the function definition.)
def balance_finder(amount):
if amount < 0:
amount -= 10;
elif amount == 0:
amount -= 5;
elif (amount > 0 and amount < 500):
amount -= 1;
elif (amount > 500 and amount < 1000):
amount += int(amount / 100);
else:
amount += int(amount / 100) * 2;
print ("Your balance is: ", amount);
done = False;
while not done:
amount = int(input("Please enter your balance (or type '00' to exit): "));
if amount == 00:
done = True;
print ("Goodybye.");
else:
balance_finder(amount);
input()to int, you're always going to get an int. What's the issue?00is octal!00is just0, but e.g.015is13and09is a syntax error.