Hi! Thanks for your reply!
Unfortunately this doesn`t help, because:
As per Programiz, The count()
method returns the number of times the specified element appears in the list.
In this practice problem, we have to find the number that appears the most, so the element is unknown.
DQ gives us this answer to our practice problem:
Given a list of numbers, find the number that appears the most.
values = [72, 50, 48, 50, 7, 66, 62, 32, 33, 75, 30, 85, 6, 85, 82, 88, 30, 32, 78, 39, 57, 96, 45, 57, 61, 32, 10, 62, 48, 32, 96, 75, 15]
most_frequent = values[0]
for value in values:
if values.count(value) > values.count(most_frequent):
most_frequent = value
print (most_frequent)
Can you explain this code to me? or someone else? Thank you!