Advertisement
zhukov000

Queue

Nov 8th, 2019
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. queue = []
  2.  
  3. while True:
  4.   cmd = input()
  5.   if cmd == "exit":
  6.     print("bye")
  7.     break
  8.   elif cmd == 'pop':
  9.     print( queue.pop(0) )
  10.   elif cmd == 'front':
  11.     print( queue[0] )
  12.   elif cmd == 'size':
  13.     print( len(queue) )
  14.   elif cmd == 'clear':
  15.     queue.clear()
  16.     print('ok')
  17.   else:
  18.     c, n = cmd.split()
  19.     queue.append(n)
  20.     print('ok')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement