Tuples and sets · 9 / 16 Exercise Medium

Common elements

Objective

Create a Python program that shows the numbers that appear in two lists at once, using the intersection of sets.

Instructions

  • Read two lines. Each one contains integers separated by spaces.
  • Convert each line into a set of integers.
  • Show, on a single line, the common numbers sorted from smallest to largest and separated by a space.
  • If there is no common number, show None.
Input
1 2 3 4
3 4 5
Output
3 4

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise