I have just started using python and am trying to write a program that generates 200 random numbers in the range (1,50),then counts the number of occurrences of each number and prints the frequency of occurrence.

I have created the part of the code which generates the random numbers.

I need help in counting the frequency of these numbers.

However, all i would like is a push in the right direction. At the moment i am trying to do this using a for loop. How would i go about that.
Thanks

numbers = random_numbers(1, 50, count=200)
counts = [0 for range(50+1)]
for number in numbers:
# add count of number
print_nicely(counts[1:], start=1) # drop zero count as it is not possible

Then make functions to generate the numbers (random_numbers) and output the results (print_nicely)

Read up on accessing a list by the index 10.2 Lists are mutable, here, as well as the writing or updating comments in 10.3. Initialize a list (using a for loop to append zero each time) so it has one element equaling zero up to the maximum number+1. Under a new loop, generate a number using randint. The number will correspond to the list. So if the number is 5, add one to element #5 of the list, etc. I can't do it for you, but post back with code for any part that isn't working.

Thanks for your help guys. I created a list full of zero's and updated each element by adding one to it by assigning the randint function to a variable
Waz

Hi everyone!, I had this confusion about the the Bucket Sort Algorithm.
I just wanna know why mostly bucket sort use the range of element in between 0 and 1 ...