Python newbie here, unsure if this is the correct method but i’m having issues when trying to get the following to run:
from Meal_Options import usual_meals, healthy_meals, hot_meals, other_meals, lunch_meals, fast_food_meals print("Hello! Lets decide what you want for lunch! Please answer the first question.") lunch_tea = input("Is it lunch, or tea? ").lower() if lunch_tea == "lunch": print(*lunch_meals, sep="n") elif lunch_tea == "tea": healthy = input("Healthy or not healthy? ").lower() if healthy == "healthy": food_type = input("Do you want spicy or not spicy? ").lower if food_type == "not spicy": print(*healthy_meals, sep="n") print(*usual_meals, sep="n") print(*other_meals, sep="n") elif food_type == "spicy": print(*hot_meals, sep="n") elif healthy == "not healthy" or "unhealthy": pizza_chinese_indian = input("Do you want pizza, chinese or indian? ").lower if pizza_chinese_indian == "pizza": print(*fast_food_meals) elif pizza_chinese_indian == "chinese": print(*fast_food_meals) elif pizza_chinese_indian == "indian": print("Ok, Korma it is") elif lunch_tea != "tea" or "lunch": print("n" "Invalid input, please enter 'Tea' or 'Lunch'") finished = input("Are you happy with your selection? ").lower
Output:
Hello! Lets decide what you want for lunch! Please answer the first question. Is it lunch, or tea? tea Healthy or not healthy? not healthy Do you want pizza, chinese or indian? chinese Are you happy with your selection? no
Why does the code not print anything when answering “pizza“, “chinese” or “indian” and just moves onto “Are you happy with your selection?”
Advertisement
Answer
I believe the main issue here is that you are forgetting to add the ()
after the str.lower
method.
from Meal_Options import usual_meals, healthy_meals, hot_meals, other_meals, lunch_meals, fast_food_meals ... if lunch_tea == "lunch": print(*lunch_meals, sep="n") elif lunch_tea == "tea": ... if healthy == "healthy": food_type = input("Do you want spicy or not spicy? ").lower() ... elif healthy == "not healthy" or "unhealthy": pizza_chinese_indian = input("Do you want pizza, chinese or indian? ").lower() ... ... finished = input("Are you happy with your selection? ").lower()
I’ve copied only the relevant code in order to highlight exactly where the issues are.