Why am I getting this error? (python)

Discussion in 'Programming General' started by kmjt, Nov 4, 2010.

Why am I getting this error? (python)
  1. Unread #1 - Nov 4, 2010 at 1:07 AM
  2. kmjt
    Joined:
    Aug 21, 2009
    Posts:
    14,450
    Referrals:
    8
    Sythe Gold:
    449

    kmjt -.- The nocturnal life chose me -.-
    Banned

    Why am I getting this error? (python)

    For this problem i'm working on I don't get why it's not working. This is what I get when I try to run the program:

    When I enter yes to continue that is the error I get..


    This is my code:

    Code:
    import random
    
    
    
    def main():
    
        
            
        number1 = random.randint(1,10)
        number2 = random.randint(1,10)
    
    
        outcome = number1 + number2
    
    
        print number1, "+", number2, "=", outcome
    
    
        proceed = raw_input("Continue? (yes/no): ")
    
    
        while proceed == yes:
            proceed()
           
            
    
    
    
    def proceed():
        
            number1 = random.randint(1,10)
            number2 = random.randint(1,10)
    
    
            outcome = number1 + number2
    
            print number1, "+", number2, "=", outcome
            
    
    
        
    main()
    
     
  3. Unread #2 - Nov 4, 2010 at 5:57 AM
  4. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Why am I getting this error? (python)

    I don't know what programming language this is, but I'll say what I think the error means and maybe it will help in some way.

    Code:
    NameError: global name 'yes' is not defined
    To me that sounds like it's treating yes as a variable, and it hasn't been defined but it's trying to access its value.
     
  5. Unread #3 - Nov 4, 2010 at 8:47 AM
  6. kmjt
    Joined:
    Aug 21, 2009
    Posts:
    14,450
    Referrals:
    8
    Sythe Gold:
    449

    kmjt -.- The nocturnal life chose me -.-
    Banned

    Why am I getting this error? (python)

    It's python.
     
  7. Unread #4 - Dec 10, 2010 at 10:59 AM
  8. Aeropsia
    Joined:
    May 11, 2010
    Posts:
    27
    Referrals:
    0
    Sythe Gold:
    0

    Aeropsia Member

    Why am I getting this error? (python)

    Try putting yes in quotation marks.
     
< New here, seeking advice | code to parse an array of hostnames into ips >

Users viewing this thread
1 guest


 
 
Adblock breaks this site