Lesson 8/19: Why do I get an error message when I use random = random.randint(1 - 9) in my code when even the example has a similar version


#1

Please why do I get an error message when I use random = random.randint(1 - 9) in my code when even the example has a similar version. It tells me that “random is not defined”

thon

The lesson only passes me when I remove random:

Kindly explain


#2

there are multiply ways to import, you could just import the module:

import random

then you would have to do random.randint, but you only imported the function:

from random import randint

so then you only need to use the function, not the module name


#3

Thanks for the explanation.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.