Combined Supply List with set()
Two classroom teams are preparing supplies for the same workshop. Each team wrote its own list of needed items, and some names appear on both lists. The teacher now wants one clean checklist without repeated item names.
Your task is to combine the two lists and return a new list containing each item only once. To make the final checklist easy to read, the returned list should be sorted in alphabetical order.
For example, if the lists are ["glue", "paper", "tape"] and ["paper", "markers", "glue"], the result should be ["glue", "markers", "paper", "tape"]. Even though "glue" and "paper" appear in both inputs, they should appear only once in the final answer.
If both input lists are empty, the answer should be an empty list. This challenge is about merging collections, removing duplicates, and producing a clean final result.
Example Input & Output
A repeated item stays only once in the sorted result.
Items from both lists are merged, duplicates are removed, and the result is sorted.
Two empty lists produce an empty combined checklist.
Algorithm Flow

Solution Approach
This problem combines two separate ideas that fit together nicely. First, you need to remove duplicates. Second, you need the final answer in alphabetical order. Python's set is very helpful for the first part because sets only keep unique values.
A clean way to solve it is to convert both lists into sets, combine them, and then sort the result:
The operator | performs a union. That means it keeps every distinct item that appears in either input collection. If an item appears in both lists, it still ends up only once in the union set.
After that, sorted() turns the unique items into a list and places them in alphabetical order. That last step matters because sets do not preserve a predictable display order, while the problem explicitly asks for a sorted list.
You could also write the union with the method form set(team_a).union(team_b). That is equally correct. The important data-structure idea is that sets are ideal when the problem cares about unique membership rather than repeated occurrences.
This approach stays concise without hiding the logic. Build a unique collection first, then arrange it in the output format the problem wants. The runtime is roughly O(n + m + k log k), where k is the number of distinct items being sorted.
Best Answers
def combine_supplies(team_a, team_b):
return sorted(set(team_a) | set(team_b))Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
