Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I'm starting to learn list.append by passing a string to the parameter in the function, However I'm getting an error, how can I solve this issue?
list.append
Here's my code:
def add_more(name): name.append(5) name=[1,2,3,4] print add_more(name)
print add_more(name)
print(add_more(name))
While the variable name does get altered as a pass by reference, if you're going to print it out, you'll need to add a return statement to your function
def add_more(name): name.append(5) return name name=[1,2,3,4] print add_more(name)
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
print add_more(name). Should beprint(add_more(name))