this is a pretty basic question but here goes:
I would like to create an array and then would like to compare a user input to those elements within the array.
If one element is matched then function 1 would run. If two elements were matched in the array the an alternative function would run and so on and so forth.
Currently i can only use an IF statement with no links to the array as follows:
def stroganoff():
print ("You have chosen beef stroganoff")
return
def beef_and_ale_pie():
print ("You have chosen a beef and ale pie")
return
def beef_burger():
print ("You have chosen a beef burger")
return
ingredients = ['beef','mushrooms','ale','onions','steak','burger']
beef = input("Please enter your preferred ingredients ")
if "beef" in beef and "mushrooms" in beef:
stroganoff()
elif "beef" in beef and "ale" in beef:
beef_and_ale_pie()
elif "beef" in beef and "burger" in beef:
beef_burger()
As said, this is basic stuff for some of you but thank you for looking!
arraydo you meanarrayorlist? As in python both are similar but different things. If you want list, you already have oneingredients = ['beef','mushrooms','ale','onions','steak','burger']. Please can you be little clear about your intentions here.