Hey, I'm new to python so don't judge.

Steve D'Aprano steve+python at pearwood.info
Tue Jan 3 20:15:57 EST 2017

On Wed, 4 Jan 2017 12:04 pm, Callum Robinson wrote:

> Traceback (most recent call last):
>   File "D:/Python/random.py", line 6, in <module>
>     computer_number = number.randint(1, 100)
> NameError: name 'number' is not defined

That's exactly what we need to see! The full traceback, thank you!

You're asking Python to get the variable "number", and call the randint
method. But:

- you don't have a variable called "number";

NameError: name 'number' is not defined

- and even if you did, that's not how you get a random number. What you want

computer_number = random.randint(1, 100)

“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

More information about the Python-list mailing list