I have an array [1,2,3,4,5,6,1,2,3,4] and I would like to return 5, 6.
If I use set(my_array) I get 1,2,3,4,5,6. Is there a pythonic way to do this. Thanks.
Any help is much appreciated.
I have an array [1,2,3,4,5,6,1,2,3,4] and I would like to return 5, 6.
If I use set(my_array) I get 1,2,3,4,5,6. Is there a pythonic way to do this. Thanks.
Any help is much appreciated.
#List of data which has every item repeated except for 5 and 6
lst= [1,2,3,4,5,6,1,2,3,4]
#This list comprehension prints a value in the list if the value only occurs once.
print [x for x in lst if lst.count(x)==1]
#Output
[5, 6]