reversing a subarray

🏠

Say you have the following array:

1A = [0,1,2,3,4,5,6,7,8,9]

How would you reverse the subarray from index 3 to 6 inclusive?

Solution:

1A = [0,1,2,3,4,5,6,7,8,9]
2A[3:7] = reversed(A[3:7])
3print(A)

Output:

1[0, 1, 2, 6, 5, 4, 3, 7, 8, 9]