How to reverse the elements of a sub-list in a nested list with Python

1 Answer

0 votes
nestedlist = [[1, 2, 3], [1, 5], [6, 1, 8, 9, 10], [1, 9, 10, 10], [1]]

nestedlist[0].reverse() # first sub_list

print(nestedlist)



'''
run:

[[3, 2, 1], [1, 5], [6, 1, 8, 9, 10], [1, 9, 10, 10], [1]]

'''

 



answered Feb 9, 2025 by avibootz
...