• Log in or sign up for an account here: https://www.sythe.org/login

Why am I getting this error? (python)

kmjt

-.- The nocturnal life chose me -.-

Banned
Joined
Aug 21, 2009
Sythe Gold
449
Messages
14,450
Location
Canada
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:

6 + 2 = 8
Continue? (yes/no): yes

Traceback (most recent call last):
File "/Users/loganpytyl/Documents/question3assignment3.py", line 47, in <module>
main()
File "/Users/loganpytyl/Documents/question3assignment3.py", line 27, in main
while proceed == yes:
NameError: global name 'yes' is not defined

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()
 
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.
 
It's python.
 
Runescape Gamblingrunescape gambling
Back
Top