| Store | Cart

[Tutor] Function question

From: Peter ODoherty <kevi...@gmail.com>
Sat, 25 Mar 2017 10:01:21 +0000
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  -  Tut...@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Recent Messages in this Thread
Peter ODoherty Mar 25, 2017 10:01 am
Alan Gauld via Tutor Mar 25, 2017 11:17 am
Peter ODoherty Apr 01, 2017 07:24 pm
Peter ODoherty Apr 01, 2017 07:24 pm
Sri Kavi Mar 25, 2017 12:04 pm
Messages in this thread