-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek07_2.py
More file actions
33 lines (29 loc) · 769 Bytes
/
week07_2.py
File metadata and controls
33 lines (29 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
book = input()
m = int(input())
leftPage = [book[0]]
rightPage = []
for elem in range(len(book) - 1, 0, -1):
rightPage.append(book[elem])
for _ in range(m):
action = input()
if action == 'prev':
if len(leftPage) == 1:
continue
else:
rightPage.append(leftPage.pop())
elif action == 'next':
if len(rightPage) == 1:
continue
else:
leftPage.append(rightPage.pop())
elif action == 'left':
if len(leftPage) == 1:
continue
else:
leftPage.pop()
elif action == 'right':
if len(rightPage) == 1:
continue
else:
rightPage.pop()
print(leftPage[len(leftPage) - 1], rightPage[len(rightPage) - 1])