[source code] Python Programming Tutorial - 20 - Dictionaries

+4 Bucky Roberts · September 2, 2014

classmates = {'Tony': 'cool but smells', 'Emma': 'sits behind me', 'Lucy': 'asks too many questions'}
weights = {'Tony': 150, 'Emma': 87, 'Lucy': 385}


print(classmates)
print(classmates['Emma'])


for k, v in weights.items():
   print(k + " weighs " + str(v))

Post a Reply

Replies

Oldest  Newest  Rating
+1 Mason Farina · September 2, 2014
Thanks for this info, Bucky! Really helped with my project :)
0 zeal patel · February 3, 2015
I saw your this tutorial but i have one doubt in my mind that output for this program it always changes in order. It is not showing in the order. So what to do for sorting in order as we define in the code.

Thank you,
zeal Patel
  • 1

Python

118,544 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator