Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 600 Bytes

File metadata and controls

34 lines (24 loc) · 600 Bytes

reverse

reverse()

The reverse() method doesn't return any value. It updates the existing list.

#The original array
arr = [11, 22, 33, 44, 55]
print("Array is :",arr)

res = arr[::-1] #reversing using list slicing
print("Resultant new reversed array:",res)

[::-1]

#The original array
arr = [11, 22, 33, 44, 55]
print("Array is :",arr)

res = arr[::-1] #reversing using list slicing
print("Resultant new reversed array:",res)

reverse part of array

def reverse_sublist(lst,start,end):
    lst[start:end] = lst[start:end][::-1]
    return lst