Advertisement
pacho_the_python

Untitled

Feb 23rd, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # 9 70 -56 9 9
  2.  
  3. nums = list(map(int, input().split(" ")))
  4.  
  5. command = input().split()
  6. value = int(command[1])
  7. replacement = int(command[2])
  8. counter = 0
  9. for i in range(len(nums)):
  10.     if command[0] == "Replace":
  11.         if nums[i] == value:
  12.             nums.remove(value)
  13.             nums.insert(i, replacement)
  14.             counter += 1
  15.         if counter >= 1:
  16.             break
  17. print(nums)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement