Advertisement
jbonanno

dictionary.py

Jul 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1.  
  2. #This creates a data dictionary of musicians including the id, genre, talent, and country.
  3. musicians ={
  4.              "Joe": {"id": "1", "age": 25, "genre": "heavy metal", "talent": "singer", "country": "United States"},
  5.              "Jackie": {"id": "2", "age": 20, "genre": "country", "talent": "Harmonica", "country": "United States"},
  6.               "Mark": {"id": "3", "age": 18, "genre": "psychadelic rock", "talent": "guitar", "country": "U.K."},
  7.               "Jenna": {"id": "4", "age": 21, "genre": "pop", "talent": "singer", "country": "Sweden"},
  8.               "Moe":  {"id": "5", "age": 30, "genre": "heavy metal", "talent": "drums", "country": "Germany"}
  9.              }
  10.  
  11. #This obtains and prints the entire data dictionary.
  12. print ("Here is the entire data dictionary printed")
  13. print (musicians)
  14. #This obtains and prints Jackie's genre, selecting one item from the data dictionary.
  15. print ("Here is Jackie's genre:")
  16. print (musicians["Jackie"]["genre"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement