Hi,

Apologies for the very basic question but could anyone explain the behaviour of these two functions (in Python3.5)?

def myFunc(num):
    for i in range(num):
        print(i)

print(myFunc(4))
0
1
2
3
None #why None here?


def myFunc(num):
    for i in range(num):
        return i

print(myFunc(4))
0 #why just 0?

Many thanks,
Peter


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to