开发者

Python - Quick Integer List Creation

开发者 https://www.devze.com 2023-02-12 05:45 出处:网络
Can I make a list of numbers from开发者_JS百科 1 to 6 in one line without a loop? goal: [1,2,3,4,5,6]

Can I make a list of numbers from开发者_JS百科 1 to 6 in one line without a loop?

goal:

[1,2,3,4,5,6]


Yes, use:

range(1,7)

that should do it.


Use the range builtin.

range(1, 7)
0

精彩评论

暂无评论...
验证码 换一张
取 消