Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 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.     try:
  9.         test = float(other_data[0])
  10.        
  11.         if key not in my_dict:
  12.             my_dict[key] = []
  13.         my_dict[key].extend(other_data)
  14.         """"if we replace lines 25-27 with the following line:
  15.        my_dict[key] = my_dict.get(key, []) + other_data
  16.        Judge - 100/100, else 60/100"""
  17.        
  18.     except ValueError:
  19.         if data[1] in my_dict:
  20.             my_dict[key] = my_dict[data[1]]
  21.     data = input()
  22.  
  23. for key, value in my_dict.items():
  24.     print(f"{key} === " + ", ".join(value))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement