Skip to content
Advertisement

Python : Unable to get output for my code . whenever I enter the array element its not able to pick array element as the answer

Fav_Food_List = ['Pizza','Burger','Cake',]
Favourite_Food = input("Enter name of your favorite food")

for Favourite_Food in Fav_Food_List:
    if Fav_Food_List == Favourite_Food :
        print ("Yep! So amazing!")
    else:
        print("Yuck! That's not it!")
print("Thanks for playing!")

Advertisement

Answer

You can do this:

Favourite_Food = input("Enter name of your favorite food")

if Favourite_Food in Fav_Food_List:
     print ("Yep! So amazing!")
else:
     print("Yuck! That's not it!")
print("Thanks for playing!")```
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement