Python Practice Lab
easyUnit 7 · Dictionaries & Sets

P20. Two List Comparison

Dictionaries & Sets

Read two lists of integers. First remove duplicates from the first list while keeping the original order (use a set to remember what you have already seen). Then use set operations to compare the two lists.

Input Format

  • Line 1: the first list
  • Line 2: the second list

Output Format

  • Line 1: Without duplicates: <list>
  • Line 2: Common: <sorted list>
  • Line 3: Union: <sorted list>
  • Line 4: Only in first: <sorted list>

Constraints

  • 1 ≤ size of each list ≤ 100
  • -1000 ≤ each integer ≤ 1000

Sample Test Cases

Sample 1
Input
3 1 3 2 1
2 3 5
Output
Without duplicates: [3, 1, 2]
Common: [2, 3]
Union: [1, 2, 3, 5]
Only in first: [1]
Sample 2
Input
1 2 3
4 5 6
Output
Without duplicates: [1, 2, 3]
Common: []
Union: [1, 2, 3, 4, 5, 6]
Only in first: [1, 2, 3]

Submitting checks 2 sample cases and 3 hidden test cases.

Hints

Saved
Custom 1

This is your own input, so Run will show what your program prints but can't say whether it's correct.