Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = int(input())
- # create main global space
- # it is flat dictionary construction
- spaces = {'global':{
- 'parent': None,
- 'vars': {}
- }}
- count = 1
- # add more in exist spaces
- def add(arg1,arg2):
- global count
- spaces[arg1]['vars'][arg2] = count
- count+=1
- # create a new spaces
- # we sign the previous space every time when we create a space in 'parent'
- def create(arg1,arg2):
- spaces[arg1] = {'parent':arg2,'vars':{}}
- # get information about spaces
- def get(arg1,arg2):
- if arg2 in spaces[arg1]['vars']:
- print(arg1)
- elif spaces[arg1]['parent'] == None:
- print('None')
- else:
- get(spaces[arg1]['parent'],arg2)
- if 1 <= num <= 100:
- for i in range(num):
- command = input().split(" ")
- if command[0] == "add":
- add(command[1],command[2])
- elif command[0] == "create":
- create(command[1],command[2])
- elif command[0] == "get":
- get(command[1],command[2])
- else:
- print("Unknowm command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement