Advertisement
simeonshopov

SoftUni Parking

Feb 4th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. n = int(input())
  2. people = {}
  3.  
  4. def check_input(lst: list, num: int):
  5.     return len(lst) >= num
  6.  
  7. for _ in range(n):
  8.     command = input().split()
  9.     cmd = command[0]
  10.     if cmd == 'register' and check_input(command, 3):
  11.         name = command[1]
  12.         plate = command[2]
  13.         if name in people:
  14.             print(f'ERROR: already registered with plate number {people[name]}')
  15.         else:
  16.             people[name] = plate
  17.             print(f'{name} registered {plate} successfully')
  18.     elif cmd == 'unregister' and check_input(command, 2):
  19.         name = command[1]
  20.         if name not in people:
  21.             print(f'ERROR: user {name} not found')
  22.         else:
  23.             print(f'{name} unregistered successfully')
  24.             del people[name]
  25.  
  26. [print(f'{x} => {y}') for (x, y) in people.items()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement