When you use range(6) it returns 0,1,2,3,4,5. Your code returns a 60-30-10 list.
import random
from statistics import mode
numlist = []
for i in range(7):
numlist.append(random.randint(1, 4))
for i in range(2):
numlist.append(random.randint(1, 3))
for i in range(1):
numlist.append(random.randint(1, 2))
Here it is wrapped in an function that lets you determine how many decades to include in your output.
import random
# stt for seven-twenty-ten
def stt_split(n=1):
# returns lists with lengths that are multiples of ten
numlist = []
for decades in range(n):
for i in range(7):
numlist.append(random.randint(1, 4))
for i in range(2):
numlist.append(random.randint(1, 3))
for i in range(1):
numlist.append(random.randint(1, 2))
return numlist
alice = stt_split()
print(alice) # 10 values in a list
bob = stt_split(4)
print(bob) # 40 values in a list
On the other hand, if you don't want a list with a set distribution returned, but you want the function to return a value calculated by a randomly selected function, you could try something like this.
import random
# stt for seven-twenty-ten
def stt_dice(n=1):
# returns lists of random ints with length n
numlist = []
for decades in range(n):
x = random.choices([2, 3, 4], [2, 1, 7])[0]
numlist.append(random.randint(1, x))
return numlist
alice = stt_dice()
print(alice) # 1 value in a list
bob = stt_dice(10)
print(bob) # 10 values in a list