Advertisement
Guest User

02.array_modifyer

a guest
Sep 19th, 2022
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. numbers = list(map(int, input().split()))
  2. command = input()
  3.  
  4. while command != 'end':
  5.     command_list = command.split()
  6.     action = command_list[0]
  7.     if action == 'swap':
  8.         swap_one = int(command_list[1])
  9.         swap_two = int(command_list[2])
  10.         numbers[swap_one], numbers[swap_two] = numbers[swap_two], numbers[swap_one]
  11.     elif action == 'multiply':
  12.         multiplier_one = int(numbers[int(command_list[1])])
  13.         multiplier_two = int(numbers[int(command_list[2])])
  14.         multiplication = multiplier_one * multiplier_two
  15.         numbers[int(command_list[1])] = multiplication
  16.     elif command == 'decrease':
  17.         for pos in range(len(numbers)):
  18.             numbers[pos] -= 1
  19.     command = input()
  20.  
  21. final_list = [str(i) for i in numbers]
  22.  
  23. print(', '.join(final_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement