0

I've got a function:

def user_login(m):
 m = "user_login function called"
 return m

Calling it with:

user_login(message)

It should change a string, m, and return the result. I know that the function gets called because it throws up an error [user_login() takes exactly 1 argument (0 given)] if I don't put an argument in it. But it doesn't return a string. How can I find out what's wrong?

asked Oct 28, 2012 at 19:00

1 Answer 1

7

You can't "change the string" - instead, what you should be doing, is assigning the result of the function to your string in the calling scope:

m = user_login('some message')
print m
answered Oct 28, 2012 at 19:02
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

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.

Ask question

Explore related questions

See similar questions with these tags.