Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- d=deque()
- f= open('input.txt')
- for s in f:
- s=s.split()
- if s[0]=='push_front':
- d.appendleft(s[1])
- print('ok')
- if s[0]=='push_back':
- d.append(s[1])
- print('ok')
- if s[0]=='pop_front':
- if len(d)>0:
- print(d.popleft())
- else:
- print('error')
- if s[0]=='pop_back':
- if len(d)>0:
- print(d.pop())
- else:
- print('error')
- if s[0]=='front':
- if len(d)>0:
- print(d[0])
- else:
- print('error')
- if s[0]=='back':
- if len(d)>0:
- print(d[len(d)-1])
- else:
- print('error')
- if s[0]=='size':
- print(len(d))
- if s[0]=='clear':
- d.clear()
- print('ok')
- if s[0]=='exit':
- print('bye')
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement