Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jack Cummins
17,417 PointsHow can I stop repeating myself
def which_resturaunt():
resturaunt = input("Do you want to go to McDonalds, Jimmy's seafood, Mickey's diner, John's steak, Joe's food court, Beacon Street Cafe, Arnold's bakey, or IHOP? ").lower()
if resturaunt == "mcdonalds":
input("""Do you want to order a:
BigMac
McNuggets
grilled chicken
Egg McMuffin
Happy Meal
""")
elif resturaunt == "jimmy's seafood":
input("""Do you want to order:
Shrimp
McNuggets
grilled chicken
Egg McMuffin
Happy Meal
""")
# so on, so on
And now, I'm going to have to start using ifs for if they pick the different food for every single resturaunt. I feel like I am definite;y violating the Dry policy (don't repeat yourself). Do you have any idea of how to use a function with parameters to solve this problem? Thanks!
Jack
1 Answer

Steven Parker
224,872 PointsHere's one idea: what if you have a dictionary where the keys are restaurants and the values are lists of menu items?
Jack Cummins
17,417 PointsJack Cummins
17,417 PointsYou are a genius!