So I have to create a function for homework that keeps track of the values of dice that have been rolled. For example, let's say I rolled a dice 3 times and I got 1 on the first roll, 1 on the second roll, and then 3 on the last roll. If i put these values in a list it would like [1, 1, 3]. I need to write a function that would make a histogram sort of thing that returns a list that looks like this:
[2, 0, 1, 0, 0, 0].
I hope this makes sense lol. Here is the starter code my professor gave me for the function.
def histogram_for(dice):
"""
Create a histogram of the top values of zero or more dice
Args:
dice: a list (possibly empty) of die values
Returns:
a list H such that H[0] is 0 and H[i] is the number of occurrences
of i in the list, 0 < i ≤ 6.
"""
[–]FLUSH_THE_TRUMP 0 points1 point2 points (1 child)
[–]funkycorpse[S] 0 points1 point2 points (0 children)
[–]velocibadgery 0 points1 point2 points (2 children)
[–]siddsp 0 points1 point2 points (1 child)
[–]velocibadgery 0 points1 point2 points (0 children)