Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- books = input().split('&')
- command = input().split(' | ')
- while not command[0] == 'Done':
- action = command[0]
- book = command[1]
- if action == 'Add Book':
- if book not in books:
- books.insert(0, book)
- elif action == 'Take Book':
- if book in books:
- books.remove(book)
- elif action == 'Swap Books':
- book2 = command[2]
- if book in books and book2 in books:
- index1 = books.index(book)
- index2 = books.index(book2)
- books[index1], books[index2] = books[index2], books[index1]
- elif action == 'Insert Book':
- if book not in books:
- books.append(book)
- elif action == 'Check Book':
- if 0 <= int(command[1]) < len(books):
- print(f'{books[int(command[1])]}')
- command = input().split(' | ')
- print(*books, sep=', ')
Advertisement
Add Comment
Please, Sign In to add comment