Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- pieces = {}
- for _ in range(n):
- data = input().split("|")
- piece, composer, key = data
- pieces[piece] = [composer, key]
- while True:
- command = input().split("|")
- if command[0] == "Stop":
- break
- elif command[0] == "Add":
- piece, composer, key = command[1:]
- if piece in pieces :
- print(f"{piece} is already in the collection!")
- else:
- pieces[piece] = [composer, key]
- print(f"{piece} by {composer} in {key} added to the collection!")
- elif command[0] == "Remove":
- piece = command[1]
- if piece in pieces:
- print(f"Successfully removed {piece}!")
- del pieces[piece]
- else:
- print(f"Invalid operation! {piece} does not exist in the collection.")
- elif command[0] == "ChangeKey":
- piece, new_key = command[1:]
- if piece in pieces:
- pieces[piece][1] = new_key
- print(f"Changed the key of {piece} to {new_key}!")
- else:
- print(f"Invalid operation! {piece} does not exist in the collection.")
- sorted_pieces = sorted(pieces.items(), key=lambda kvp: (kvp[0], kvp[1][0]))
- for piece_, composer_key in sorted_pieces:
- print(f"{piece_} -> Composer: {composer_key[0]}, Key: {composer_key[1]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement