I created a function to take a list as input and remove the duplicates without creating a new array. However, the output is wrong. How can I fix this? and is there a simpler way to do it? I am new to Python
def remove_duplicates(duplicatelist):
for i in duplicatelist:
num = 0
while num < len(duplicatelist)-1:
#the following line checks to see if there is a
#duplicate. It also makes sure that num = i is not being
#counted as duplicate because if you have a value of 2 at index 2,
#then this should not be counted as a duplicate if it's the only one
if i == duplicatelist[num] and i !=num :
duplicatelist.remove(duplicatelist[num])
num = num + 1
print(duplicatelist)
remove_duplicates([1, 1, 2, 3, 3, 4, 5, 6, 6, 6, 7])
#output is: [1, 3, 4, 6, 7] but this is wrong.