Advertisement
Guest User

Force Book

a guest
Mar 3rd, 2022
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. def line_up(up_dict: dict, side: str, user: str):
  2.     # passing the command
  3.     for total_users in up_dict.values():
  4.         if user in total_users:
  5.             return up_dict
  6.  
  7.     # completely new user and side
  8.     if side not in up_dict:
  9.         up_dict[side] = [user]
  10.         return up_dict
  11.  
  12.     # side exist, user doesn't
  13.     elif side in up_dict and user not in up_dict[side]:
  14.         up_dict[side].append(user)
  15.         return up_dict
  16.  
  17.  
  18. def side_pointer(side_dict: dict, side: str, user: str):
  19.  
  20.     # changing sides
  21.     for total_sides in side_dict.keys():
  22.         if user in side_dict[total_sides]:
  23.             side_dict[total_sides].remove(user)
  24.             side_dict[side].append(user)
  25.             print(f"{user} joins the {side} side!")
  26.             return side_dict
  27.  
  28.     # completely new user and side
  29.     if side not in side_dict:
  30.         side_dict[side] = [user]
  31.  
  32.     # side exist, user doesn't
  33.     elif side in side_dict and user not in side_dict[side]:
  34.         side_dict[side].append(user)
  35.  
  36.     print(f"{user} joins the {side} side!")
  37.     return side_dict
  38.  
  39.  
  40. command = input()
  41. side_user_dictionary = {}
  42.  
  43. while not command == "Lumpawaroo":
  44.  
  45.     if "|" in command:
  46.         split = command.split(" | ")
  47.         force_side = split[0]
  48.         force_user = split[1]
  49.         side_user_dictionary = line_up(side_user_dictionary, force_side, force_user)
  50.  
  51.     elif "->" in command:
  52.         split = command.split(" -> ")
  53.         force_side = split[1]
  54.         force_user = split[0]
  55.         side_user_dictionary = side_pointer(side_user_dictionary, force_side, force_user)
  56.  
  57.     command = input()
  58.  
  59. for key, value in side_user_dictionary.items():
  60.     if len(value) > 0:
  61.         print(f"Side: {key}, Members: {len(value)}")
  62.         for el in value:
  63.             print(f"! {el}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement