'''
Created on Mar 5, 2017

@author: Susan
'''
# which number from 0 to 100 appears the most?
# These could be test scores for example. 

def most(nums):
    maxcnt = 0
    maxnum = -1
    cnts = [0 for n in range(max(nums)+1)]
    for num in nums:
        cnts[num] += 1
        if cnts[num] > maxcnt:
            maxcnt = cnts[num]
            maxnum = num
    return maxnum

print most([2,3,5,8,5,3,5,2,5,3])
print most([2,3,1,1,5,1,8,5,1,3,5,1,2,5,3])

    
def most2(nums):
    maxcnt = 0
    maxnum = -1
    for num in set(nums):
        cnt = nums.count(num)
        if cnt > maxcnt:
            maxcnt = cnt 
            maxnum = num
    return maxnum
            
        
if __name__ == '__main__':          
        
    print most2([2,3,5,8,5,3,5,2,5,3])
    print most2([2,3,1,1,5,1,8,5,1,3,5,1,2,5,3])