Selecting multiple elements from array python
<p>this is a pretty basic question but here goes:</p>

<p>I would like to create an array and then would like to compare a user input to those elements within the array.</p>

<p>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.</p>

<p>Currently i can only use an IF statement with no links to the array as follows:</p>

<pre><code>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()
</code></pre>

<p>As said, this is basic stuff for some of you but thank you for looking!</p>

<p>You may do something like:</p>

<pre><code># Dictionary to map function to execute with count of matching words
check_func = {
    0: func_1,
    1: func_2,
    2: func_3,    
} 

ingredients = ['beef','mushrooms','ale','onions','steak','burger']
user_input = input()

# Convert user input string to list of words
user_input_list = user_input.split()

# Check for the count of matching keywords
count = 0
for item in user_input_list:
    if item in ingredients:
        count += 1

# call the function from above dict based on the count
check_func[count]()
</code></pre>

python arrays python-3.x