I am testing a reverse function. My code is as follow:
def deep_reverse(L):
new_list = []
for element in L:
new_list += [element[::-1]]
L = new_list[::-1]
L = [[1, 2], [3, 4], [5, 6, 7]]
deep_reverse(L)
print(L)
I expect my output L can be like [[7, 6, 5], [4, 3], [2, 1]], but it only works inside my function.
I wasn't able to change it in the global variable. How can I make it happen? Thank you