0

I'm new to python so don't judge too harshly. I have researched this for a couple hours but I haven't gotten were I want too.

results = {}
counter = 1
pastabake = "Pastabake recipie:"
pittapizzas = "Pitta Pizzas recipie:"

while True:
    response = input("Which ingredients do you have?");
    results[counter] = response
    counter +=  1
    if counter == 6:
        break
    if response == ('pasta' and 'onion' and 'cheese' and 'garlic'):
        print(pastabake)

What is happening is that once I run it, It only takes the prints pastabake once I type in the last response, which is "garlic", instead of taking all of them in any order before printing pastabake.

I don't understand what im doing wrong? Any help appreciated, Thanks.

MD9
  • 105
  • 2
  • 14

1 Answers1

1

You are testing against multiple variables wrong, just put them in a list and check if the desired value is in the list:

results = {}
counter = 1
pastabake = "Pastabake recipie:"
pittapizzas = "Pitta Pizzas recipie:"

while True:
    response = input("Which ingredients do you have?");
    results[counter] = response
    counter +=  1
    if counter == 6:
        break
    if response in ['pasta', 'onion', 'cheese', 'garlic']:
        print(pastabake)
A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76
  • Thanks, I have tried you're suggesting of using if response in ['pasta', 'onion', 'cheese', 'garlic']: but it does the same thing except now it prints pastabake whenever the input is pasta – MD9 Mar 28 '16 at 01:51