I\'m supposed to create a function, which input is a list and two numbers, the function reverses the sublist which its place is indicated by the two numbers. for example this is
Just use a slice:
>>> lst = [1, 2, 3, 4, 5] >>> lst[0:len(lst[3::-1])]=lst[3::-1] >>> lst [4, 3, 2, 1, 5]
Or, perhaps easier to understand:
>>> lst = [1, 2, 3, 4, 5] >>> sl=lst[3::-1] >>> lst[0:len(sl)]=sl >>> lst [4, 3, 2, 1, 5]