Try this instead:
lst = [None] * 10
The above will create a list of size 10, where each position is initialized to None. After that, you can add elements to it:
lst = [None] * 10
for i in range(10):
lst[i] = i
Admittedly, that's not the Pythonic way to do things. Better do this:
lst = []
for i in range(10):
lst.append(i)
Or even better, use list comprehensions like this:
[i for i in range(10)]
Hope this will help!
If you need to know more about Python, join Python certification course online today.
Thanks!