Quotes help make search much faster. Example: "Practice Makes Perfect"

Friday, November 30, 2012

Codecademy: remove_duplicates


#sample solution


listOfNums = [1,2,3,4,3,1,2]
def remove_duplicates(listOfNums):
listOfNums.sort()
uniqueList = [1]
uniqueList[0] = listOfNums[0]
index=0
for num in listOfNums:
if uniqueList[index] != num:
uniqueList.append(num)
index = index + 1
return uniqueList
print remove_duplicates(listOfNums)

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts