How can I return only the element/s with no duplicate in the list?
e.g.
list = [1,4,5,1,5] to [4]
How can I return only the element/s with no duplicate in the list?
e.g.
list = [1,4,5,1,5] to [4]
 
    
     
    
    You can use Counter() 
from collections import Counter as counter 
list = [1,4,5,1,5]
c = counter(list)
print(*[item for item, time in c.items() if time==1], sep='\n')
Output :
C:\Users\Desktop>py x.py
4
 
    
    def unique(list1):
for i in list1:
    if(list1.count(i)==1):
        return i 
list1 = [10, 20, 10, 30, 40, 40]  
print(unique(list1))
list2 =[1, 2, 1, 1, 3, 4, 3, 3, 5]  
print(unique(list2))
