List index out of range


#1

Hey! can you help me with my bag? I don’t see it:

remove_duplicates function

Blockquote
def remove_duplicates(num):
rm=[]
n=len(num)
i=1
rm.append(num[0])
while i<n:
b=True
for j in range(i):
if num[i]!=num[j]:
b=b and True
else:
b=False
if b==True:
rm.append(num[i])
if i<n:
i+=1
else:
break

print rm
return rm

print remove_duplicates([3,2,2,5,6])


#2

this:

rm.append(num[0])

will give an error when the list would be empty:

print remove_duplicates([])

#3

Thank you very much!


#4

the error message in the bottom of the screen also indicated this?