Print a list in reverse order with range()?

前端 未结 19 796
长发绾君心
长发绾君心 2020-11-30 17:09

How can you produce the following list with range() in Python?

[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
19条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 17:42

    for i in range(8, 0, -1)
    

    will solve this problem. It will output 8 to 1, and -1 means a reversed list

提交回复
热议问题