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


Can somebody explain the difference below please?

for i in range(len(x)):

Instead of 

for i in x:


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()


Great thanks for explanation.