Code not working

by Akshat chaudhari   Last Updated October 19, 2019 06:24 AM - source

i am new to python 2 and am learning. the following program to remove duplicate numbers from a list and return the new list with all duplicates removed is showing list index out of range. i don't know why?This the code for it. Can someone tell what is wrong?

def remove_duplicates(list1): list2 = [] list2.append(list1[0]) for i in range(0, len(list1)): if list1[i] not in list2: list2.append(list1[i]) return list2

Tags : support


Related Questions




Why is my Stack Overflow account inaccessible?

Updated March 26, 2015 07:30 AM

Favourite tags?

Updated April 03, 2015 21:27 PM