I am new to this python language: I am facing issues to display the unique elements in the list in the following pgm: Below are my program:
def unique_list(lst):
c = []
for i in lst:
if (lst.count(i)>=1) & i not in c:
c.append(i)
#print(c)
return c
print(unique_list([1,1,1,2,2,3,3,4,5]))
I received the output as:
[1,2,2,4]
instead of [1,2,3,4,5]
i think there is a mistake in the if stmt... can anyone explain me y am i getting this output??