11.New Entries


#1



https://www.codecademy.com/en/courses/python-beginner-en-pwmb1/2/2?curriculum_id=4f89dab3d788890003000096#


There are 4 items on the menu.
{'Choclate Fudge': 156.23, 'Chicken Chap': 250, 'Sizzler': 150, 'Biriyani': 170}
None


There are 4 items on the menu.
{'Sizzler': 150, 'Chicken Chap': 250, 'Biriyani': 170, 'Choclate Fudge': 156.23}
None


menu = {} # Empty dictionary
 # Adding new key-value pair

# Your code here: Add some dish-price pairs to menu!
menu["Sizzler"] = 150
menu["Chicken Chap"] = 250
menu["Biriyani"] = 170
menu["Choclate Fudge"] = 156.23

print "There are " + str(len(menu)) + " items on the menu."
print menu


#2

The Problem is python should Print the list the way i have written the code but it is not not printing like that . It is printing like "{'Choclate Fudge': 156.23, 'Chicken Chap': 250, 'Sizzler': 150, 'Biriyani': 170}
None"
but my expectation is that it should print like "There are 4 items on the menu.
{'Sizzler': 150, 'Chicken Chap': 250, 'Biriyani': 170, 'Choclate Fudge': 156.23}
None"
what am i missing plz help


#3

ok, first I am new to python, I am still learning.

it's the print order you are concerned with?

dictionaries are a data type that is unordered and meant to be referenced by its key.


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.