How to implement a function that remove duplicates from list in Python

1 Answer

0 votes
def remove_duplicates(lst):
    lstreturn = []

    for value in lst:
        if value not in lstreturn:
            lstreturn.append(value)

    return lstreturn


lst = ["python", "java", "python", "c", "c", "php", "c"]

lst = remove_duplicates(lst)

print(lst)




'''
run:

['python', 'java', 'c', 'php']

'''

 



answered Oct 24, 2020 by avibootz

Related questions

...