How do I reverse a part (slice) of a list in Python?

Just use the slice and reverse it.

a[2:4] = a[2:4][::-1]

Leave a Comment