I'm trying to practice some for loops. I would like to print one value from two separate lists and then join them together. I was able to get it to print what I wanted with if
/elif
statements but I don't know if there is a better way to do it.
Desired output:
John eats Mexican
Marissa eats Japanese
Pete eats French
Dayton eats American
Here is the code that I tried:
persons = [ "John", "Marissa", "Pete", "Dayton" ]
restaurants = [ "Japanese", "American", "Mexican", "French" ]
for person in persons:
for restaurant in restaurants:
if person == "John" and restaurant == "Mexican":
print(person + " eats " + restaurant)
elif person == "Pete" and restaurant == "French":
print(person +" eats " + restaurant)
elif person == "Dayton" and restaurant == "American":
print(person +" eats " + restaurant)
elif person == "Marissa" and restaurant == "Japanese":
print(person +" eats " + restaurant)
I want to know what else is possible and what could make my code more efficient.