I want to generate a list of length n which contains n random unique integers, ordered by numerical value and with a difference of no more than 10 between any two elements.
I wrote this function:
import random
def make_list(n):
list = []
num = 0
for i in range(30):
num = num + random.randint(1,10)
list.append(num)
return(list)
It works but it seems verbose and I feel like there should be a better, more concise way using list comprehensions or other.