To generate a list of random numbers in Python, put random.randint() inside a list comprehension: [random.randint(1, 100) for _ in range(10)] gives you ten whole numbers from 1 to 100. Need them all different? Use random.sample(range(1, 101), 10) instead:
import random
numbers = [random.randint(1, 100) for _ in range(10)] # repeats allowed
unique = random.sample(range(1, 101), 10) # no repeats
I ran every snippet here on Python 3.12.5 with NumPy 2.5.3, and each one calls random.seed() first, so you’ll get exactly the lists I show.
In this tutorial, we’ll build a list of random numbers in Python with integers, unique picks, floats and prices, repeatable seeds and NumPy for big lists, then simulate a week of sales.
Generate a list of random integers with randint()
random.randint(a, b) returns one integer where both ends are included. Call it once per slot in a list comprehension, and the _ just means you don’t need the loop counter:
import random
random.seed(7)
numbers = [random.randint(1, 100) for _ in range(10)]
print(numbers)
print("length:", len(numbers), "| duplicates:", len(numbers) - len(set(numbers)))
Output:
[42, 20, 51, 84, 7, 10, 69, 13, 47, 75]
length: 10 | duplicates: 0

Every call is independent, so repeats can happen. For a single value, my guide to generating a single random number in Python covers randint, randrange and friends.
Generate unique random numbers with random.sample()
random.sample(population, k) picks k items without replacement, so nothing repeats. A range works as the population:
import random
random.seed(2026)
tickets = random.sample(range(1, 70), 5) # 5 unique numbers from 1-69
print("Unique picks:", tickets)
print("Sorted: ", sorted(tickets))
try:
random.sample(range(1, 11), 12) # asking for more than exist
except ValueError as err:
print("ValueError:", err)
Output:
Unique picks: [16, 41, 65, 66, 14]
Sorted: [14, 16, 41, 65, 66]
ValueError: Sample larger than population or is negative

The error text is Sample larger than population or is negative, so check k against the range size first. To pick from a list of names or products instead of numbers, see randomly selecting from a list in Python.
Generate a list of random floats and prices
random.random() returns a float from 0.0 up to (but not including) 1.0. For another range, random.uniform(a, b) scales it, and round(x, 2) turns it into a dollar amount:
import random
random.seed(11)
rates = [random.random() for _ in range(4)]
print("0-1 floats:", [round(r, 4) for r in rates])
prices = [round(random.uniform(9.99, 49.99), 2) for _ in range(6)]
print("Prices:", [f"${p:.2f}" for p in prices])
print(f"Total: ${sum(prices):.2f}")
Output:
0-1 floats: [0.4524, 0.5598, 0.9242, 0.4657]
Prices: ['$30.30', '$33.49', '$17.38', '$30.47', '$35.19', '$41.71']
Total: $188.54
The prices only look neat because of :.2f; real money math belongs in decimal.Decimal. For the 0-to-1 case, read generating random numbers between 0 and 1 in Python.
Want only the prices above $30.00? You can do that with a comprehension, and filtering lists in Python shows that plus filter().
How do I get the same random list every time?
Seed the generator. random.seed(42) resets the hidden state, so the same seed always produces the same sequence.:
import random
random.seed(42)
first = [random.randint(1, 50) for _ in range(6)]
random.seed(42)
second = [random.randint(1, 50) for _ in range(6)]
print(first)
print(second)
print("Same list:", first == second)
rng = random.Random(42) # its own generator, own state
print([rng.randint(1, 50) for _ in range(6)])
Output:
[41, 8, 2, 48, 18, 16]
[41, 8, 2, 48, 18, 16]
Same list: True
[41, 8, 2, 48, 18, 16]
Both seeded lists match, and the random.Random(42) instance gives that same list too. I prefer an instance in bigger programs, since other code can’t reset it.
Once you’ve got a list you like, printing it cleanly for a report is covered in printing a list without brackets in Python.
Generate a big list of random numbers with NumPy
For thousands or millions of values, NumPy’s default_rng() is much faster than a Python loop. Note that integers(1, 101) excludes the high end, unlike randint:
import numpy as np
rng = np.random.default_rng(seed=2026)
ints = rng.integers(1, 101, size=8) # high end is exclusive
print(ints, type(ints).__name__)
print(ints.tolist(), type(ints.tolist()).__name__)
big = rng.integers(0, 1_000, size=1_000_000)
print(f"{big.size:,} numbers, min {big.min()}, max {big.max()}")
Output:
[86 18 3 64 37 47 8 38] ndarray
[86, 18, 3, 64, 37, 47, 8, 38] list
1,000,000 numbers, min 0, max 999

rng.integers() returns an ndarray; .tolist() turns it into a plain Python list.The older np.random.randint still works, but NumPy recommends the Generator API, which my NumPy random tutorial walks through.
Simulate a list of random daily sales in USD
This example combines the pieces. It builds seven seeded daily totals for the week of March 2, 2026, then reports the best day and the week’s total:
import random
from datetime import date, timedelta
random.seed(2026)
start = date(2026, 3, 2)
sales = [(start + timedelta(days=i), round(random.uniform(800, 2500), 2)) for i in range(7)]
for day, amount in sales:
print(f"{day:%a %b %d, %Y} ${amount:>9,.2f}")
best = max(sales, key=lambda s: s[1])
print(f"Best day: {best[0]:%A} at ${best[1]:,.2f}")
print(f"Week total: ${sum(a for _, a in sales):,.2f}")
Output:
Mon Mar 02, 2026 $ 1,002.50
Tue Mar 03, 2026 $ 1,654.28
Wed Mar 04, 2026 $ 1,670.10
Thu Mar 05, 2026 $ 2,262.00
Fri Mar 06, 2026 $ 974.48
Sat Mar 07, 2026 $ 1,179.58
Sun Mar 08, 2026 $ 1,821.75
Best day: Thursday at $2,262.00
Week total: $10,564.69

Each item is a tuple, and max(..., key=...) finds the top day. If you store records as objects instead, sorting a list of objects by attribute in Python explains the same key idea.
A few more random-value tutorials you can try:
- Generate random 4-digit numbers in Python
- Generate a random string of a set length
- Generate a random prime number in Python
- Random colors and moves with Python turtle
Frequently asked questions
How do I generate a list of random numbers in Python?
Use a list comprehension with random.randint(), for example [random.randint(1, 100) for _ in range(10)].
How do I generate random numbers without duplicates?
Use random.sample(range(1, 101), 10). It picks without replacement, so every value is unique.
Why does random.sample() raise ValueError?
You asked for more items than the population has. k must be no larger than the range or list size.
How do I get the same random list each run?
Call random.seed(42) (any fixed number) before generating, or use a random.Random(42) instance.
How do I make a NumPy random array a Python list?
Call .tolist() on it, for example np.random.default_rng(1).integers(1, 101, size=8).tolist().
Where are the random module functions documented?
See the random module page in the Python docs.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn