thenickname
thenickname

Reputation: 6975

Python - Quick Integer List Creation

Can I make a list of numbers from 1 to 6 in one line without a loop?

goal:

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

Upvotes: 1

Views: 382

Answers (2)

Anon.
Anon.

Reputation: 60053

Use the range builtin.

range(1, 7)

Upvotes: 0

Mic
Mic

Reputation: 6981

Yes, use:

range(1,7)

that should do it.

Upvotes: 4

Related Questions