I'm trying to check if the list have something in common. If they have one print "x" but if they don't print "y". But only one of them, not both. Code:
lista_1 = [1, 2, 4, 5, 6, 7, 8]
lista_2 = [10, 12, 16, 5, 3, 2]
for i in lista_1:
if i in lista_2:
print ('Tienen un elemento en común')
break
exit()
if i not in lista_2:
print ('No tienen ningún elemento en común')
With this way it prints x once and y once, but I want to print only one of them