I'm new to python, i was writing a functionality in which i'll have a list of values, i'll check if any value is duplicate and if its a duplicate i'm removing that from the list.
Here is the code
ds=['abhi','shek','km']
def check_duplicate(ids):
if ids in ["abhi","shek"]:
return True
return False
for s in ds:
isduplicate = check_duplicate(s)
print("s:",s)
if isduplicate:
ds.remove(s)
print(ds)
in the end i expected the list to have just one value i.e ds=['km']
, but it had 2 values i.e ds=['shek','km']
, can you please explain why it is so?