Advertisement
eNeRGy90

Untitled

Jan 27th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1.  
  2. social_media_dict = {}
  3.  
  4. while True:
  5.     data = input()
  6.     if data == "drop the media":
  7.         break
  8.     command = data.split()[0]
  9.     post_name = data.split()[1]
  10.  
  11.     if command == "post":
  12.         social_media_dict[post_name] = {"likes": 0, "dislikes": 0,\
  13.                                         "comments": []}
  14.     elif command == "like":
  15.         if post_name in social_media_dict.keys():
  16.             social_media_dict[post_name]["likes"] += 1
  17.     elif command == "dislike":
  18.         if post_name in social_media_dict.keys():
  19.             social_media_dict[post_name]["dislikes"] += 1
  20.  
  21.     elif command == "comment":
  22.         author = data.split()[2]
  23.         content = data.split()[3:]
  24.         if post_name in social_media_dict.keys():
  25.             comment = {author: content}
  26.             social_media_dict[post_name]["comments"].append(comment)
  27.  
  28. for post_name, post_data in social_media_dict.items():
  29.         print(f"Post: {post_name} | Likes: {post_data['likes']} | Dislikes: {post_data['dislikes']}")
  30.         print("Comments:")
  31.         if not post_data['comments']:
  32.             print("None")
  33.             continue
  34.         for comment in post_data['comments']:
  35.             for current_post in comment:
  36.                 print(f'*  {current_post}: {" ".join(comment[current_post])}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement