sandbox/array_shifter.py
2024-11-02 14:14:15 +03:00

9 lines
360 B
Python

def priorities_shifter(element_to_move, index_to_place, initial_array):
initial_array.remove(element_to_move)
initial_array.insert(index_to_place, element_to_move) # Insert the element at the desired index
return initial_array
if __name__ == "__main__":
initial_array = [0,1,2,3,4,5,6,7]
print(priorities_shifter(5, 1, initial_array))