runtime
126 / 500
question 126 Comprehensions · medium

Tags in the order they were used

A film page shows its tags in the order fans first used them, each tag once, ignoring capitals and spaces at the ends. tags_in_order does merge the repeats, but the page now lists the tags alphabetically, which buries the tag most people used first. Fix it so the first-seen order is kept.

Functiontags_in_order(tags)
tagsa list of tags as typed
Returnsa list of cleaned tags (stripped, lower-case), each once, in the order each first appears
Keepthe function name and that it returns a list
Examples
calltags_in_order(['time travel', 'Noir', 'noir ', 'heist', 'Time Travel'])returns['time travel', 'noir', 'heist']
calltags_in_order(['drama'])returns['drama']
calltags_in_order(['b', 'a', 'b'])returns['b', 'a']

Loading your progress…

Tags in the order they were used — Python practice · Runtime