-3

Can you help me for removing duplicate items in a list in python3 please ? for example the input list is : ['2001', '0', '3c4d', '15', '0', '0', 'db8', '1a2b']

and output : ['2001', '0', '3c4d', '15', 'db8', '1a2b']

axDev
  • 1

1 Answers1

0
OUTPUT = list(set(INPUT))

To preserve order:

OUTPUT = list(dict.fromkeys(INPUT)) # Credit to @Jab

Converts to a set of unique items, then back into list form.

Larry the Llama
  • 958
  • 3
  • 13