Advertisement
Guest User

Array Modifier

a guest
Jul 8th, 2020
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. numbers = list(map(int, input().split()))
  2.  
  3. while True:
  4.     command = input().split()
  5.     if command[0] == 'end':
  6.         print(', '.join(map(str, numbers)))
  7.         break
  8.     elif command[0] == 'decrease':
  9.         numbers = [x - 1 for x in numbers]
  10.     elif command[0] == 'swap':
  11.         numbers[int(command[1])], numbers[int(command[2])] = numbers[int(command[2])], numbers[int(command[1])]
  12.     elif command[0] == 'multiply':
  13.         numbers[int(command[1])] *= numbers[int(command[2])]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement