- 2

Input_num = [1,2,3,4,5,6,7,8,9,10]. Print(input_num[0:5] + input_num[:4:-1]) #output [1,2,3,4,5,10,9,8,7,6]

Explain the above program about reverse function

6th Jun 2021, 2:03 PM
Santhosh kumar
Santhosh kumar - avatar
1 Answer
0
Since the beginning index is not given for the second slice -1 is taken as the starting index since the step value is negative
8th Jun 2021, 2:13 PM
Aathi Sankar