Remove_duplicates


#1

I am stuck at remove_duplicates

used the code given below to solve the problem and also got correct results from https://repl.it

nlist = []
def remove_duplicates(lst):
    for i in lst:
        if i in nlist:
            break
        else:
            nlist.append(i)
    return nlist


#2

W.r.t. to your code, You need to put nlist inside of the function so it does not get past values when CC tests,also get rid of break and use pass..
break will make your code get halt early.


#3

everything you need to remove duplicates should be inside the function, this include nlist = [], otherwise, if you call the function multiply times, there will be left overs in nlist from earlier function calls

also, why do you have break? This will break the loop, why would you want this?


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.