List manipulation in function:


#1

n = [3, 5, 7]

Add your function here

def list_extender(lst):
list_extender(lst).append(9)
return list_extender(lst)
print list_extender(n)

IT GIVES AN ERROR MESSAGE: list_extender([1, 2, 3, 4]) resulted in an error: 'function' object has no attribute 'append'
WHATS THE PROBLEM IN THIS CODE


#2

here:

list_extender(lst).append(9)

you call the function inside the function, why? to append to a list you can simply do:

listName.append("value you want to append")

same for your return on the next line, just return the list, don't call the function


#3

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