What is a point for range(len(x)?


#1



Can somebody explain the difference below please?


for i in range(len(x)):
    print(x[i])

Instead of 

for i in x:
    print(i)


#2

well, range() gives us indexes, which we can then use to update elements in the list, lets say x is a list with integers we could do:

for i in range(len(x)):
    x[i] = x[i] + 3

This not possible with your second approach

so the best one to use depends on what you need to do, if you just need to print, i wouldn't use range()


#3

Great thanks for explanation.


#4