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! While you're at it, check out some resources Treehouse students have shared here.
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 trialSuresh N
743 PointsCode runs in Workspace, but fails in Challenge window. Need help
hi I am sure there is some mistake in my code. Need help on that.
On another note, i am experiencing this kind of issues in most of the challenges, wherein it runs successfully in Workspace. It would be great if i get the same error in Workspace as well, the Treehouse admins pls consider to take a note of this.
def favorite_food(dict):
name=input("Whats your name?")
while name!="":
name=input("Whats your name?")
food=input("What would you like to eat?")
while food!="":
food=input("What would you like to eat?")
dict={"name":name,"food":food}
print("Hi, I'm {name} and I love to eat {food}!".format(**dict))
favorite_food(dict)
1 Answer
Majid Bilal
3,558 PointsYou simply need to unpack the passed in dictionary:
def favorite_food(dict):
print("Hi, I'm {name} and I love to eat {food}!".format(name=dict['name'], food=dict['food']))