okay could someone explain: range(len(list)), ok range creates a list but why do we use len(i know that it show us how long is something(lol))


Hi @microsolver81105,

Your query is a little vague.

Yes, len does give you the number of elements in a list. So, len([1, 2, 3, 4, 5]) gives 5. This helps us in constructing a list indexes by:

x = [1, 2, 3, 4, 5]
indexes = range(len(x)) # => [0, 1, 2, 3, 4]

whose elements correspond to the indexes in x which you can then loop over and use to access elements in x by sequential order.

Hope it helps!


so len(x) checks the list how many elements in x it has and with the range we create a new list with 5 elements.


Yes. You are correct!


thank you very much :slightly_smiling: