pyassistant

Remove duplicates preserving order (strings)

Write a function that removes duplicate strings from a list while preserving the order of first occurrences. The function should return a new list containing only the first occurrence of each string from the original list, keeping their original relative order. Notes: - Comparison should be case-sensitive ("Apple" and "apple" are different). - The input list may be empty; in that case return an empty list. - Do not sort the list; preserve the order of first appearances.

Example:

Input:
(['apple', 'banana', 'apple', 'orange', 'banana'])
Output:
['apple', 'banana', 'orange']

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.