DiYane

Array modifier

Sep 16th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. numbers = [int(el) for el in input().split()]
  2.  
  3. command = input().split()
  4.  
  5. while not command == 'end':
  6.     com = command[0]
  7.     if com == 'end':
  8.         break
  9.     if com == 'swap':
  10.         numbers[int(command[1])], numbers[int(command[2])] = numbers[int(command[2])], numbers[int(command[1])]
  11.     elif com == 'multiply':
  12.         numbers[int(command[1])] *= numbers[int(command[2])]
  13.     if com == 'decrease':
  14.         numbers = [x - 1 for x in numbers]
  15.  
  16.     command = input().split()
  17.  
  18. print(', '.join(str(el) for el in numbers))
Tags: python
Add Comment
Please, Sign In to add comment