-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeck_Python_Errors.py
57 lines (44 loc) · 1.37 KB
/
Deck_Python_Errors.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from collections import deque
def main():
d = deque([])
while True:
input_line = input()
console_command = (input_line.split(' '))[0]
if console_command == 'push_front':
number = int(input_line.split(' ')[1])
d.appendleft(number)
print('ok')
if console_command == 'push_back':
number = int(input_line.split(' ')[1])
d.append(number)
print('ok')
if console_command == 'pop_front':
if len(d) != 0:
print(d.popleft())
else:
print('error')
if console_command == 'pop_back':
if len(d) != 0:
print(d.pop())
else:
print('error')
if console_command == 'front':
if len(d) != 0:
print(d[0])
else:
print('error')
if console_command == 'back':
if len(d) != 0:
print(d[-1])
else:
print('error')
if console_command == 'size':
print(len(d))
if console_command == 'clear':
d.clear()
print('ok')
if console_command == 'exit':
print('bye')
break
if __name__ == '__main__':
main()