How to create a list of tuples with random numbers in Python

1 Answer

0 votes
import random

l = [(random.randrange(0, 30), random.randrange(0, 20)) for i in range(5)]
 
print(l)
 
 
'''
run:

[(18, 14), (13, 4), (9, 4), (22, 5), (8, 3)]
 
'''

 



answered Dec 2, 2019 by avibootz
...