Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. data = input()
  2. my_dict = {}
  3.  
  4. while data != "end":
  5.     data = data.split(" -> ")
  6.     key = data[0]
  7.     other_data = data[1].split(", ")
  8.  
  9.     if key not in my_dict:                  ###Diff1
  10.         my_dict[key] = []
  11.  
  12.     try:
  13.         test = float(other_data[0])
  14.         my_dict[key].extend(other_data)
  15.         """"if we replace lines 11-13 with the following line:
  16.       my_dict[key] = my_dict.get(key, []) + other_data
  17.       Judge - 100/100, else 60/100"""
  18.  
  19.     except ValueError:
  20.         if data[1] in my_dict:
  21.             my_dict[key] += my_dict[data[1]]                ###Diff2
  22.     data = input()
  23.  
  24. for key, value in my_dict.items():
  25.     if my_dict[key]:                                        ###Diff3
  26.         print(f"{key} === " + ", ".join(value))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement