just working on a homework question where it asks to produce a dice rolling program where one or two numbers may be more likely to print than the rest. For example 2 and/or 3 might be 10% or 20% more likely to print than other elements on the dice. I got the code up to the point where I can get it to print a random number on the dice but can't figure out how to have a weighted output.
input:
def roll_dice(n, faces = 6):
rolls = []
rand = random.randrange
for x in range (n):
rolls.append(rand(1, faces + 1 ))
return rolls
print (roll_dice(5))
output:
[5, 11, 6, 7, 6, 5]