Hi, im trying to count the number of times i roll dices of 1, 6 with x numbers of dices. But I cant understand how to import the randomlist into my next function. Can someone please explain this? I have this code, I know there is probably a much easier way of doing this but…
import random
def kast(n):
randomlist = []
for i in range(0, n):
n = random.randint(1,6)
randomlist.append(n)
print(randomlist)
return(randomlist)
def finn_antall(randomlist):
terninger = randomlist(n)
antall_1 = 0
antall_2 = 0
antall_3 = 0
antall_4 = 0
antall_5 = 0
antall_6 = 0
for num in terninger :
if num == 1:
antall_1 +=1
elif num == 2:
antall_2 +=1
elif num == 3:
antall_3 +=1
elif num == 4:
antall_4 +=1
elif num == 5:
antall_5 +=1
elif num == 6:
antall_6 +=1
print()
n = int(input('Hvor mange terninger vil du kaste? '))
kast(n)
finn_antall(kast)