
March 29th, 2004, 02:44 AM
|
 |
Contributing User
|
|
Join Date: Jan 2004
Posts: 103
Time spent in forums: 3 Days 1 h 17 m 20 sec
Reputation Power: 10
|
|
Hehe,yes,probably because you weren't inputing a defined answer...In the example,you need to type in "your first function here" or "your second function here" or "quit" to get a response(I didn't know what words you used for your functions,or how many functions you have etc.Perhaps posting more of your code would avoid this in the future).Otherwise it just loops thru until you type in a response it reconizes.Perhaps I should have worded it better and included the "else" statement that I assumed you would use...That was very general example,but maybe one thats a little more specific was called for:
Code:
thankyou = "Thank You For Using OS Calc, Version X \n"
while True:
print 'You can calculate "Total" or "Average" Savings, or "Quit"'
choice = raw_input('What would you like to calculate? ')
if choice == 'Total':
amount = input("\nEnter The Amount Saved Per Period: ")
period = input("Enter The Amount of Periods: ")
print "Amount Saved: ", amount*period
print thankyou
elif choice == 'Average':
amount = input("\nEnter The Total Amount Saved: ")
period = input("Enter The Amount of Periods: ")
print "Average Amount Saved Per Period: ", amount/period
print thankyou
elif choice == 'Quit':
print '\n'+thankyou+'Good Bye!'
break
else:
print '\nInvalid input!\n'
Code Block Generated With Py2Html
p.s. Incase you're wondering, whenever I put a '\n' in there,it's just for spacing to make things easier on the eye.It's the equivalent of typing and hitting <enter> to skip a line.
|