Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. #Jeffrey Zhang
  2. #March 10, 2020
  3. #Dictionaries
  4.  
  5. my_dictionary= {
  6.   'lol': 'laughing out loud',
  7.   'brb': 'be right back',
  8.   'btw': 'by the way',
  9.   'lmk': 'let me know',
  10.   'gtg': 'got to go',
  11.   'stfu': 'shut the freak up',
  12.   'smh': 'shaking my head',
  13.   'ikr': 'ikr know right'
  14. }
  15.  
  16. while True:
  17.   ask = input ("What do you want to do: get, add, delete, get entire dictionary ")
  18.   if ask == "get":
  19.     key = input ("What is the key? ")
  20.     print (my_dictionary.get(key, "Sorry, I could not find the definition"))
  21.   if ask == "add":
  22.     key = input ("What word would you like added? ")
  23.     value = input ("What definition do you want to go along with the key? ")
  24.     my_dictionary[key] = value
  25.     print (my_dictionary)
  26.   if ask == "delete":
  27.     key = input ("What would you like removed? ")
  28.     del my_dictionary[key]
  29.     print (my_dictionary)
  30.   if ask == "get entire dictionary":  
  31.     print (my_dictionary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement