Python: enumerate over a slice with negative indices

后端 未结 0 924
梦毁少年i
梦毁少年i 2021-01-13 12:27

I want to iterate over and enumerate the last few items of a list:

a = [1,2,3,4,5]

[c for c, i in enumerate(a[-3:], -3)] gives:

相关标签:
回答
  • 消灭零回复
提交回复
热议问题