This question already has an answer here:
I am new to python so please keep that in mind during the duration of this question.
So, I am trying to create an IF statement that basically incorporates a list and says that:
IF something from an input statement above = something on the list then it prints a certain thing
Else
prints a different thing
This is what I have so far for code:
def main():
favoriteThing = ["item0", "item1", "item2", "item3", "item4"]
question = input("What is your favorite item?")
if(question = (favoriteThing[0]) or (favoriteThing[1]) or (favoriteThing[3]) or (favoriteThing[4]))
print("Awesome! That is one of my favorite things as well!!!")
print("Here is a list of my top 5 favorite things!")
print(favoriteThing)
else:
print("Cool!!! That thing is not in my top 5 though. Here is a list of my top 5 favorite things!")
print(favoriteThing)
main()
Needless to say I am getting an error for the IF statement. I was just wandering if there was a way to do what I hope you can see what I am trying to do without having to have a loop and a bunch of elif statements. I was thinking something like multiple OR statements if that is a thing. I am not sure.
Thank You!!!
Aucun commentaire:
Enregistrer un commentaire