Advertisement
Spocoman

02. Array Modifier

Nov 8th, 2023
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. numbers = list(map(int, input().split(' ')))
  2.  
  3. while True:
  4.     command = input()
  5.     if command == "end":
  6.         break
  7.     elif command == "decrease":
  8.         for i in range(len(numbers)):
  9.             numbers[i] -= 1
  10.     else:
  11.         command, index1, index2 = command.split(' ')
  12.         index1 = int(index1)
  13.         index2 = int(index2)
  14.         if command == "swap":
  15.             value = numbers[index1]
  16.             numbers[index1] = numbers[index2]
  17.             numbers[index2] = value
  18.         else:
  19.             numbers[index1] *= numbers[index2]
  20.  
  21. print(", ".join(map(str, numbers)))
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement