So, after searching the internet for hours, though I found some related stuff, still could not find what I am looking for. In my code I provide 6 inputs. After that input I have managed to insert them into a list(), and find the biggest number with max(). I need to find the frequency (how many times that number was repeated, not what is that number). In google I have found like what is the most repeated number, but not how many times it was repeated. For example, if the user inputs 1,1,2,2,2,3 ,first output of the max() is already 3. What about how to get the frequency of the largest number 3, which is repeated only once. So the output that I am looking for is 1. It will look like this: The biggest number is: 3 The occurrence of the greatest number is: 1
I have already managed to get biggest number output as I mentioned, but not the occurrence. Waiting for your response:
Number_1 = int(input("Please type your 1st number: "))
Number_2 = int(input("Please type your 2nd number: "))
Number_3 = int(input("Please type your 3rd number: "))
Number_4 = int(input("Please type your 4th number: "))
Number_5 = int(input("Please type your 5th number: "))
Number_6 = int(input("Please type your 6th number: "))
listNumbers = [Number_1, Number_2, Number_3, Number_4, Number_5, Number_6]
maxNumber = max(listNumbers)
print("The largest number is ", maxNumber)
#Most occurrent
def most_frequent(List):
return max(set(List), key = List.count)
*THE OCCURRENCE NUMBER CODE GOES HERE*