chirag maliwal added the comment:
a = [0, 1, 2, 3, 4, 1, 2, 3, 5]
for i in a:
if a.count(i) > 1:
a.remove(i)
print(a)
"""
Output
[0, 4, 1, 2, 3, 5]
"""
It's working fine for the above code.
Yes I can use set for
Change by chirag maliwal :
--
title: list.Count() isn't working as expected for the series of same numbers in
a list -> list.count() isn't working as expected for the series of same numbers
in a list
___
Python tracker
<https:/
New submission from chirag maliwal :
a = [1,1,1,1]
for i in a:
if a.count(i) > 1:
a.remove(i)
print(a)
"""
Output:
[1,1]
expected:
[1]
"""
--
files: test.py
messages: 370239
nosy: cmaliwal
priority: normal
severity: normal
statu