def mode(L):
shows = []
modeList = []
L.sort()
length = len(L)
for num in L:
count = L.count(num)
shows.append(count)
print 'List = ', L
maxI = shows.index(max(shows))
for i in shows:
if i == maxI:
if modeList == []:
mode = L[i]
modeList.append(mode)
print 'Mode = ', mode
elif mode not in modeList:
mode = L[i]
modeList.append(mode)
print 'Mode = ', mode
return mode
mode(L)
I can't seem to iterate through my list properly...
I can successfully get the first Mode to return Mode = 87
using the 2nd for-loop however, I can't get it to search the rest of the list so that it will also return Mode = 92
I've deleted my attempts at Mode = 92
, can someone help fill in the blanks?