Shipping code normalizer
Shipping labels arrive in mixed case and sometimes contain hyphens for readability. Remove all hyphens, uppercase the remaining letters and digits, discard duplicate normalized codes, then print the unique codes alphabetically. Do not confuse two labels that differ only before normalization.
Input
One line of space-separated non-empty codes containing letters, digits and optional hyphens.
Output
Normalized distinct codes, one per line in alphabetical order.
Example 1
Input
ab-12 AB12 x-9 X9
Output
AB12 X9
ab-12 and AB12 become the same normalized code, while x-9 and X9 collapse into one second code.
Constraints
- The line contains 1 to 200 non-empty codes.
- Codes contain only ASCII letters, digits and separator hyphens.
Hints
Hint 1 of 2
Use replace('-', '') before changing case.
Hint 2 of 2
A set removes duplicates after normalization; sort it for reporting.
Solution
Show a reference solution and explanation
codes = {code.replace('-', '').upper() for code in input().split()}
for code in sorted(codes):
print(code)
Why it works
Normalization must precede deduplication, or ab-12 and AB12 would be treated as different shipments. A set retains one normalized form of each code. Sorting at the end gives a deterministic report regardless of input order.
Lesson for this exercise: Strings in Python