lundi 22 août 2016

if statement always takes first condition python

I am working on a basic python programme where I input a recipe I want to make and the quantity I want to make and the programme should calculate how much of each ingredient I need based on an excel file with the quantities per liter and subtracts the amounts I used from another excel file which contains a list of ingredients I have at home. this should be usable for multiple recipes and I tried this using a raw input and an if statement as can be seen below. However, the programme always uses the first recipe. Also when my input asks for the second recipe.

recipe = raw_input("give recipe ")
quantity = input("give quantity ")
print

if recipe == 'recipe1':
    wb1 = load_workbook('recipe1.xlsx')
elif recipe == 'recipe2':
    wb1 = load_workbook('recipe2.xlsx')

any help would be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire