Return in the function


#1

Hi, I am thinking is defining a return in a function is a must in Python? The code below does not has any return word, but it can still run. May I know is it compulsory for me to define return inside the function somehow? Thanks

n = [3, 5, 7]

def print_list (x) :
for i in range(0, len(x)):
print x[i]

print_list (n)


#2

no, you can perfectly fine have a function with no return, you can simple let the function print something like you did. return isn't mandatory, but super useful in some situations