Skip to content
Sign upLog in
← Back to Community
random integer
Profile icon
AnnaBuell

How do I get my program to select a random integer between 1 and 100?

Voters
Profile icon
EdwardDarkins
Profile icon
AnnaBuell
Comments
hotnewtop
Profile icon
AllAwesome497

This is how you get a random number:

import random # At the beginning of the file random_number = random.randint(<lowest number>, <highest number>) # Choose a number between arg 1 and arg 2, includes the top and bottom numbers
Profile icon
HackermonDev

@AllAwesome497
is correct. And maybe when you ask for someone to guess a number turn the number into with int(input()) before you compare it.