28 lines
511 B
Python
28 lines
511 B
Python
def removeDuplicates(somelist):
|
|
seen = set()
|
|
result = []
|
|
|
|
for i in somelist:
|
|
if i not in seen:
|
|
seen.add(i)
|
|
result.append(i)
|
|
|
|
return result
|
|
|
|
def main():
|
|
#Create a list with duplicates
|
|
somelist = [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9]
|
|
|
|
#Display the list
|
|
print(somelist)
|
|
|
|
#Use the remove duplicates function to remove duplicate values
|
|
list_parsed = removeDuplicates(somelist)
|
|
|
|
print(list_parsed)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
|