Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def swap(array_values_, idx1, idx2):
- array_values_[idx1], array_values_[idx2] = array_values_[idx2], array_values_[idx1]
- return array_values_
- def multiply(array_values_, idx1, idx2):
- array_values_[idx1] *= array_values_[idx2]
- return array_values_
- def decrease(array_values_):
- array_values_ = [n - 1 for n in array_values_]
- return array_values_
- def array_modifier():
- array_values = [int(x) for x in input().split()]
- while True:
- command = input()
- if command == 'end':
- break
- data = command.split()
- current_command = data[0]
- if current_command == "swap":
- index1, index2 = int(data[1]), int(data[2])
- array_values = swap(array_values, index1, index2)
- elif current_command == "multiply":
- index1, index2 = int(data[1]), int(data[2])
- array_values = multiply(array_values, index1, index2)
- elif current_command == "decrease":
- array_values = decrease(array_values)
- print(", ".join(map(str, array_values)))
- array_modifier()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement