Python Forum

Full Version: Help with randint/random
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to learn how to do the randint function by searching online but when I ever I try using what websites say, I get an error message and I want to understand what I'm doing wrong. This is what I copied from websites and get an error with:
import random

print random.randint(0,5)
Am I missing something? Any help would be appreciated, thanks in advance.
You need to include the error message when you get one.

I'm guessing it's because you're using Python 2 examples when you have Python 3 installed. You need to use parenthesis with print, like so:
print(random.randint(0,5))