def reverseUpToIndex(lst, index):
if (index > len(lst)):
print("Index out of range")
return
for i in range(0, (int)(index / 2)):
temp = lst[i]
lst[i] = lst[index - i - 1]
lst[index - i - 1] = temp
lst = [1, 4, 8, 0, 7, 3, 9, 5, 6]
index = 5
reverseUpToIndex(lst, index);
print(lst)
'''
run:
[7, 0, 8, 4, 1, 3, 9, 5, 6]
'''