Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shelf=input().split('&')
- command=input()
- while command!='Done':
- command_list=command.split(' | ')
- if command_list[0]=='Add Book':
- book_name=command_list[1]
- if book_name not in shelf:
- shelf.insert(0,book_name)
- elif command_list[0]=='Take Book':
- book_name=command_list[1]
- shelf.remove(book_name)
- elif command_list[0]=='Swap Books':
- book1=command_list[1]
- book2=command_list[2]
- a, b = shelf.index(book1), shelf.index(book2)
- shelf[a],shelf[b]=shelf[b], shelf[a]
- elif command_list[0]=='Insert Book':
- book_name = command_list[1]
- shelf.insert(len(shelf), book_name)
- elif command_list[0]=='Check Book':
- index=int(command_list[1])
- if 0<=index<len(shelf):
- print(shelf[index])
- command=input()
- print(', '.join(shelf))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement