#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    28
    Rep Power
    0

    need help newbie


    print 'welcome to greek eatery'
    print 'we are full \n '
    money = int(raw_input('how much to tip ?'))
    if money:
    print 'we have a table'
    else:
    print 'sit down and wait'
    raw_input('press the enter key to exit')


    # i want the program to display 'we have a table' if i enter a
    $ amount
    # and display 'sit down and wait' if i enter o
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    103
    Rep Power
    11
    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
    Code:
    if money > 0:
    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?!?!?

IMN logo majestic logo threadwatch logo seochat tools logo