nside of our new function called list_extender we work with the list provided as an argument: lst. This is the list we append to and then, on the next line, return in its entirety.
def function_name(parameter_list):
# Append to the list using list_name.append(value)
# Return the entire list, not just the new value
For those who have a syntax problem, its probably a font type error. Is not ‘1st’. The first letter is an l (lowcase L), wich aparently is very similar to the number one on this font.
In chapter lists and functions, in exercise 11
I am unable to directly return the appended list (return lst.append(9)).
I’m having to return lst separately in a diff line, is this normal?
Also why am I unable to directly return the lst?
n = [3, 5, 7]
# Add your function here
def list_extender(lst):
lst.append(9)
return lst
print list_extender(n)