#๐Ÿ”’ Restaurant Menu problem

59 messages ยท Page 1 of 1 (latest)

barren sigilBOT
#

@muted wadi

Python help channel opened

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.

muted wadi
#

im kinda stuck on how to create the dictionary with strings and floats

open idol
muted wadi
#

well ye but like

#

wouldnt it just be:
menu = {"Burger": 10.99, "Fries": 3.99,"Salad": 7.99,"Milkshake": 5.99}

im not sure..

open idol
#

show me what you have tried

muted wadi
#

ok great

open idol
#

now you know what to do next?

muted wadi
#

haha T_t

#

im thinking about it

open idol
#

just try things out and explore

crystal pine
#

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

open idol
#

yep

#

we also have

#

!rule hw

barren sigilBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

crystal pine
#

Yup

muted wadi
#

yeye but im allowed to ask you guys if the code is right/good?

open idol
#

ofc

crystal pine
#

Yes

#

For sure

muted wadi
#

for item in menu:
print(f'{item}: menu[item]')
that's the next part pretty sure

open idol
#

have you tested it?

muted wadi
#

wait ur right

void token
crystal pine
void token
muted wadi
#

#Question 2

menu = {"Burger": 10.99, "Fries": 3.99,"Salad": 7.99,"Milkshake": 5.99}

for item in menu:
print(f'{item}: menu[item]')

open idol
void token
muted wadi
#

I FORGOT ANOTHER PAIR OF {} AROUND MENU[ITEM] ๐Ÿ˜ญ

#

it prints out the meny now

open idol
#

now what you need to do next?

crystal pine
#

No you should make a user input and check if the input is in the menu

void token
#

If u print both the key and the value use
for key, value in dict.items()

crystal pine
#

Good luck

muted wadi
#

#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?

crystal pine
#

Try to say something not in the menu and see what happens

muted wadi
#

ye it shows the right statement, im j talking ab like the code itself tho

crystal pine
#

Yes its good

muted wadi
#

horray thanks

crystal pine
#

But

#

What if the user typed a number in the user input

muted wadi
#

it says the item is not on the menu

#

the right statement^

void token
#

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

muted wadi
void token
solemn plinth
barren sigilBOT
#
Python help channel closed

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