Advertisement
Spocoman

02. Trains

Feb 10th, 2022
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. wagons = int(input()) * [0]
  2. command = input()
  3.  
  4. while command != 'End':
  5.     current = command.split(' ')
  6.     if current[0] == 'add':
  7.         wagons[len(wagons) - 1] += int(current[1])
  8.     elif current[0] == 'insert':
  9.         wagons[int(current[1])] += int(current[2])
  10.     elif current[0] == 'leave':
  11.         wagons[int(current[1])] -= int(current[2])
  12.     command = input()
  13.  
  14. print(wagons)
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement