-5

When I try to create a .py file with return in a function like provided below

def results(s1,s2):
    return s1+s2

results(3,4)

it does not show the result when i try to run the .py file in terminal, why is it like this

And also please elaborately explain me where and how to use the RETURN statement and its purpose

4

2 回答 2

8

It doesn't show the result because you're not showing it! You have to print explicitly:

print results(3, 4)

When you call the function from Python's interactive mode, it does display the return value, but that's a convenience for development.

于 2013-04-14T16:29:23.163 回答
1

You're not printing the result. Use this:

def results(s1,s2):
    return s1+s2

print results(3,4)
于 2013-04-14T16:29:29.490 回答