I am writing a program where a user inputs data for two lists ( numbers ) and then the program outputs the matching numbers from both of the lists. I have written a bit of code to manually achieve this but I need to implement a way where the user can input numbers for themselves instead of just hardcoding them in.
see below desired output:
List 1: 1 2 3 4
List 2: 4 2 0 0
output: [4 , 2 ]
My bellow code achieves the desired result but not how it's intended, my code takes values from a list and calculates the intersection, and prints the result but not as outlined as above.
a = [1,2,3,4]
b = [4,2,0,0]
c = set(a) & set(b)
print('Output:',c)
could you please help and explain how this is achieved. thanks