Advertisement
bl00dt3ars

problem 2

Feb 27th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. train_length = int(input())
  2. train = [0] * train_length
  3.  
  4. command = input()
  5.  
  6. while "End" not in command:
  7.     text = command.split()
  8.     if "add" in command:
  9.         train[-1] += int(text[1])
  10.     elif "insert" in command:
  11.         train[int(text[1])] += int(text[2])
  12.     elif "leave" in command:
  13.         train[int(text[1])] -= int(text[2])
  14.  
  15.     command = input()
  16.  
  17. print(train)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement