def majorityelement(list1):
emt1 =0
emt1c =0
emt2 =0
emt2c = 0
count1 =0
count2 = 0
for i in range(len(list1)):
if emt1 == list1[i]:
emt1c = emt1c+1
print('list value' , list1[i] , '--> element1: ',emt1 ,'-->',emt1c)
elif emt2 == list1[i]:
emt2c = emt2c+1
print('list value' , list1[i] , '--> element2: ',emt2 ,'-->',emt2c)
elif emt1c == 0 :
emt1 = list1[i]
emt1c = emt1c +1
print('list value' , list1[i] , '--> element1: ',emt1 ,'-->',emt1c)
elif emt2c == 0:
emt2 = list1[i]
emt2c = emt2c + 1
print('list value' , list1[i] , '--> element2: ',emt2 ,'-->',emt2c)
else:
emt1c =emt1c - 1
emt2c = emt2c - 1
print('list value' , list1[i] , '--> element1: ',emt1 ,'-->',emt1c ,'|| element2 :', emt2 , '-->', emt2c)
for i in range(len(list1)):
if list1[i] == emt1 :
count1 = count1 +1
if list1[i] == emt2 :
count2 = count2 +1
'''
if count1== emt1c and count2==emt2c:
return emt1 , emt2
'''
return emt1 , emt2 , count1, count2
list1 = [1,2,3,1,2,11,1,2,5,8,9,10]
#list1 = [2, 2 , 3 ,1,3,2,1,1]
tup1 = majorityelement(list1)
print(tup1)