Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Adam Siwiec
12,070 PointsOOP question
Why do I get an NameError on numberCorrect for this class/method:
from questions import GenerateQuestion
class Quiz:
numberCorrect = 0
def take_quiz(self):
GenerateQuestion(self.numberCorrect,"+")
Here is my GenerateQuestion class:
import random
class GenerateQuestion:
text = None
answer = None
num1 = None
num2 = None
maxnum = 0
def __init__(self, scale, symbol):
self.maxnum = 2 ** scale
self.num1 = random.randint(1,self.maxnum)
self.num2 = random.randint(1,self.maxnum)
self.text = "{} {} {}".format(self.num1,symbol,self.num2)
if symbol == "+":
self.answer = self.num1 + self.num2
if symbol == "-":
self.answer = self.num1 - self.num2
if symbol == "*":
self.answer = self.num1 * self.num2
if symbol == "/":
self.answer = self.num1 // self.num2
Wairton Rebouças
8,225 PointsWairton Rebouças
8,225 PointsI've tested your code, it seems to be working fine on both python 2 and 3 on my machine. This is part of some quiz? If you are running this on your computer, what error message you got?