Python For i in range(len(str)): last iteration prints None

Viewed 1265
def fun(str):
    for i in range(len(str)):
        print(i)

string = 'abc'

print(fun(string))

print results are

0
1
2
None

if I change

for i in range(len(str)-1):

the last result is still None

Why is this? And how do I stop it?

3 Answers
Related