+ 1
How to create a list with a defined lenght?
How can I create an empty list with a defined lenght, so I don't get an error when assigning a value to an specific slot?
3 Antworten
+ 3
x = given by you
list = [0 for i in range(x)]
or
list = [0]*x
or
list = list(range(x))
+ 2
you're welcome:)
+ 1
Mbrustler thanks for your explanation :) I aprecciate it!