jbonanno icon

dictionary.py

jbonanno | PRO | 07/22/17 12:01:07 PM UTC | 0 ⭐ | 234 👁️ | Never ⏰ | []
Python |

960 B

|

None

|

0 👍

/

0 👎

 
#This creates a data dictionary of musicians including the id, genre, talent, and country. 
musicians ={
             "Joe": {"id": "1", "age": 25, "genre": "heavy metal", "talent": "singer", "country": "United States"},
             "Jackie": {"id": "2", "age": 20, "genre": "country", "talent": "Harmonica", "country": "United States"},
              "Mark": {"id": "3", "age": 18, "genre": "psychadelic rock", "talent": "guitar", "country": "U.K."},
              "Jenna": {"id": "4", "age": 21, "genre": "pop", "talent": "singer", "country": "Sweden"},
              "Moe":  {"id": "5", "age": 30, "genre": "heavy metal", "talent": "drums", "country": "Germany"}
             }
 
#This obtains and prints the entire data dictionary. 
print ("Here is the entire data dictionary printed")
print (musicians)
#This obtains and prints Jackie's genre, selecting one item from the data dictionary. 
print ("Here is Jackie's genre:")
print (musicians["Jackie"]["genre"])

Comments