Advertisement
x3m_tm

Untitled

Jun 24th, 2021
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. def fill_dictionary():
  2.     numbers_dictionary = {}
  3.    
  4.     while True:
  5.         key = input()
  6.         if key == 'Search':
  7.             break
  8.         value = input()
  9.         if value == 'Search':
  10.             break
  11.         number = int(value)
  12.         numbers_dictionary[key] = number
  13.        
  14.     return numbers_dictionary
  15.  
  16.  
  17. def find_in_store(store):
  18.     searched = input()
  19.    
  20.     while searched != "Remove":
  21.         print(numbers_dictionary.get(searched, "Number does not exist in dictonary"))
  22.         searched = input()
  23.        
  24.    
  25. def remove_from_store(numbers_dictionary):
  26.     line = input()
  27.     while line != "End":
  28.         searched = line
  29.         try:
  30.             del numbers_dictionary[searched]
  31.         except Exception:
  32.             print('Number does not exist in dictionary')
  33.             line = input()
  34.             continue
  35.        
  36.         print(numbers_dictionary)
  37.        
  38.         line = input()
  39.        
  40.  
  41. numbers_dictionary = fill_dictionary()
  42. find_in_store(numbers_dictionary)
  43. remove_from_store(numbers_dictionary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement