Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # You will receive how many wagons the train has.
  2. # Until you receive "End", you get some of the commands:
  3. #   add {people} -> adds the people in the last wagon
  4. #   insert {index} {people} -> adds the people at the given wagon
  5. #   leave {index} {people} -> removes the people from the wagon
  6. #
  7. # Input:
  8. # 3
  9. # add 20
  10. # insert 0 15
  11. # leave 0 5
  12. # End
  13. #
  14. # Output:
  15. # [10, 0, 20]
  16.  
  17. command = input()
  18. temp_list = [0] * 10
  19. results_list = []
  20.  
  21. while not command == 'End':
  22.     task_parts = command.split("-")
  23.     priority = int(task_parts[0])
  24.     note = task_parts[1]
  25.     temp_list.insert(priority, note)
  26.     command = input()
  27.  
  28. for each_item in temp_list:
  29.     if not each_item == 0:
  30.         results_list.append(each_item)
  31.  
  32. print(results_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement