List manipulation in functions


#1

During this exercise, I raised a question,

wrong code:

n = [3, 5, 7]
def list_extender(lst):
return lst.append(9)
print list_extender(n)

does anyone can tell me that the reason why the code crashed is because
when we are defining a function, we can not do any calculation after RETURN?


#2

by default, a function returns None at the end. If we want our function to return something else/different, we can use the return keyword. The catch is that, the return keyword will then end the function


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.