python-small-examples/md/70.md at master · data-python/python-small-examples

File metadata and controls

16 lines (12 loc) · 219 Bytes

@author jackzhenguo
@desc 
@date 2019/4/10

70 一行代码实现列表反转

def reverse(lst):
    return lst[::-1]


r = reverse([1, -2, 3, 4, 1, 2])
print(r)  # [2, 1, 4, 3, -2, 1]