Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- full_list={}
- while True:
- command=input()
- if command=="Last Info":
- break
- command=command.split(":")
- command[2]=int(command[2])
- if command[0]=="Add":
- if command[1] not in full_list.keys():
- full_list[command[1]]=command[1:]
- else:
- full_list[command[1]][1]+=command[2]
- if command[0] == "Feed" :
- try:
- full_list[command[1]][1]-=command[2]
- except :
- continue
- if full_list[command[1]][1]<=0:
- print (f"{command[1]} was successfully fed")
- full_list.pop(command[1])
- #Animals:
- lst=[]
- for k,v in full_list.items():
- lst.append(v[:2])
- n=sorted(lst, key=lambda x: (-x[1], x[0]))
- print ("Animals:")
- for _ in n:
- print (f"{_[0]} -> {_[1]}g")
- #Areas with hungry animals:
- print ("Areas with hungry animals:")
- areas={}
- for k,v in full_list.items():
- if v[2] not in areas:
- areas[v[2]]=1
- else:
- areas[v[2]]+=1
- for k,v in areas.items():
- print (f"{k} : {v}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement