
April 8th, 2004, 08:17 PM
|
 |
Contributing User
|
|
Join Date: Jan 2004
Posts: 103
Time spent in forums: 3 Days 1 h 17 m 20 sec
Reputation Power: 10
|
|
All you had to do was finish your "if" statement.You litterally said "if money" and that was all hehe.You need to define the "if" check on money.So in your case it would be if money is greater than zero
Basicly your "if" check has to be something that can be answered yes or no,so that you can act accordingly.The very basic idea being:
Code:
if this is true:
do this
else:
do that
And since you already know about typecasting,you can make a built-in error message if the input can't be typecast as a integer.Since this was kinda fun I got fancy and wrapped it inside a "while true" loop,so if there was a VauleError it would loop until you put in a integer
Code:
print 'Welcome To The Greek Eatery!'
print 'Unfortunately we are full right now...'
print '*wink* *wink*'
print '*extends hand*\n'
while True: #start the loop
try: #try to typecast the input and then act on it
money = int(raw_input('How much of a "tip" do you give?'))
if money > 0:
print 'A table has just become available.'
print 'Right this way,Sir...'
break #break out of the loop
else:
print 'Take a seat in the waiting area,Bub!'
break #break out of the loop
except ValueError: #if the input isn't a integer
print "\nInvaild Amount!\n"
__________________
It is not important if the glass is half full or half empty.What is important,is who has been drinking from MY glass?!?!?
|