Why isn't "import random.randint" working on the "Rock Paper Scissors" project


#1

https://www.codecademy.com/courses/learn-python/projects/rock-paper-scissors

I am trying to import randint from random.
I know I can use:

from random import randint

But the PEP 8 styleguide says to use:

import random.randint

Now, I don’t really care which one I use, but I’d really like to know why it’s saying there’s no module named randint.


#2

Because there isn’t one.

import random

print (random.randint(1, 10))    # 7

The classes of a module behave like the methods of a class only when the complete module is loaded.

from random import randint

print (randint(1, 10))   # 3

Once the class is installed as a standalone we can use it like any function.


#3

thanks for the answer i was with the same problem