#๐ Restaurant Menu problem
59 messages ยท Page 1 of 1 (latest)
@muted wadi
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
im kinda stuck on how to create the dictionary with strings and floats
do you know how a dictionary work?
well ye but like
wouldnt it just be:
menu = {"Burger": 10.99, "Fries": 3.99,"Salad": 7.99,"Milkshake": 5.99}
im not sure..
show me what you have tried
yep, pretty much like this
ok great
now you know what to do next?
just try things out and explore
Look into the exercise
If You read it well You can do it
We dont want to tell You the answers so You can think
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
Yup
yeye but im allowed to ask you guys if the code is right/good?
ofc
for item in menu:
print(f'{item}: menu[item]')
that's the next part pretty sure
have you tested it?
wait ur right
If menu is a dict[item,price] than yes
Its a dict
U could use
For k,v in menu.items():
#Question 2
menu = {"Burger": 10.99, "Fries": 3.99,"Salad": 7.99,"Milkshake": 5.99}
for item in menu:
print(f'{item}: menu[item]')
what have you forgot when using f-strings?
menu[item] is not revognised as a var by the f string
yessir
Yes
now what you need to do next?
Nice
No you should make a user input and check if the input is in the menu
If u print both the key and the value use
for key, value in dict.items()
Good luck
#Question 2
menu = {"Burger": 10.99, "Fries": 3.99,"Salad": 7.99,"Milkshake": 5.99}
for item in menu:
print(f'{item}: {menu[item]}')
user_input = input("Enter the name of a menu item you would like to order: ")
if user_input in menu:
print(f"The price of {user_input} is ${menu[user_input]}.")
else:
print("The item is not on the menu.")
the code looks good right?
Try to say something not in the menu and see what happens
ye it shows the right statement, im j talking ab like the code itself tho
Yes its good
horray thanks
i still think it looks better if u use
for key, value in menu.items():
but it works and dosent have any other thing i could say is wrong
is this just a better syntax or something
yes
They key and value you can name yourself, so could be:
for item, price in ..
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Restaurant Menu problem