Hello everyone,
I’m new here ant with python in general and I would be happy to receive support and guidance from you all.
I wrote a very easy function that should return a list of objects found in both the provided lists.
However, the code has no error but it does not return the expected outcome: the new list.
I cannot figure out the problem.
def com_country(a, b):
country = []
for x in a:
if x in b:
country.append(x)
return country
Andrea = ["Spain", "UK", "USA", "Israel", "Italy"]
Thea = ["South Africa", "USA", "Morocco", "Italy", "Israel"]
com_country(Andrea, Thea)
Thank you