-7

I'm sure python has a built in way to create an x size list where the contents are 0 through x-1, but I don't know how to do it. I've searched on Google as well as on here, I'm sure that I must've not been using the correct wording to find what I needed. Please help.

Ex: len([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) = 10

1
  • 5
    list(range(10)) Mar 28, 2018 at 18:33

1 Answer 1

5

You are looking for the range builtin:

range(x) # python 2
list(range(x)) # python 3

Not the answer you're looking for? Browse other questions tagged or ask your own question.