1from collections import Counter
2data = Counter(your_list_in_here)
3data.most_common() # Returns all unique items and their counts
4data.most_common(1) # Returns the highest occurring item
5
1import random
2numbers = []
3limit = int(input("Please enter how many numbers you would like to compare:\n"))
4mode =0
5for i in range(0,limit):
6 numbers.append(random.randint(1,10))
7
8maxiumNum = max(numbers)
9j = maxiumNum + 1
10count = [0]*j
11for i in range(j):
12 count[i]=0
13
14for i in range(limit):
15 count[numbers[i]] +=1
16
17n = count[0]
18for i in range(1, j):
19 if (count[i] > n):
20 n = count[i]
21 mode = i
22
23print("This is the mode = "+str(mode))
24print("This is the array = "+str(numbers))
25
26