I am trying to reverse slice of a list in python but it returns an empty list. But when I try with whole list, it works fine. Am I missing anything here?
l=[1,2,3,4,5,6,7,8]
l[::-1]=[8, 7, 6, 5, 4, 3, 2, 1] <<< This worked fine.
l[2:5]=[3, 4, 5]
l[2:5:-1]=[] <<< Expecting [5,4,3] here.
Any clues?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…