Learn to Code via Tutorials on Repl.it!

← Back to all posts
Python Random Number Generator Tutorial
tankerguy1917

This is a tutorial for a simple random number generator in python. if it is to hard to see in the program, here is the code

import random
from random import choice

rand_num_list = [1, 2, 3, 4, 5]

rand_num_list = choice(rand_num_list)
print(rand_num_list)

Hope you enjoy, and I hope it helps
:)

Voters
vbrownsmith
Owenkop
chriz068
tankerguy1917
Comments
hotnewtop
Owenkop

is it posible to make this select multiple numbers so it would selct 5 random numbers from the numbers (sort of like this 11385)?

tankerguy1917

@Owenkop maybe this will help. If it doesn't, just let me know and we can try to find a solution for you :)

tankerguy1917

@Owenkop Also, I made this a long time ago, and it is better to just use random.randint. The only time I'd say that you wouldn't want to use randint is if you only want a few specific numbers instead of 1 through 0.