Remove duplicates


#1

Hi guys,

this code for "remove duplicates" works for me but new_ list is not printed and I do not understand why.
I would appreciate if somebody could explain:

Thanks a lot!
Kate


#2

Hi Kate,

It's an easy fix (but the kind of thing that makes you crazy until you figure it out)! :smile:

Just remove the

print new_list

from your function definition. Returning values is usually more flexible and useful than printing them.
Then when you want to print the function with assigned variables, just call the function with print before the call:

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

Good luck!


#3

Oh, and if you do need to a function to print, I think you just would write

print new_list

in the function definition and leave the return call out.