newby qn about functions
Noah Hall
enalicho at gmail.com
Tue Jan 18 05:42:08 EST 2011
> """how can i use a return statement to write a function that returns the
> string "Testing Functions-lower case: "and the lowercase representation of
> its string parameter""" If I uncomment the above, nothing outputs to
> console:(
def lower_case(s):
return "Testing Functions-lower case: %s" % (s.lower())
>>> print(lower_case("HeLLo"))
Testing Functions-lower case: hello
>>> d = lower_case("HeLLo")
>>> print(d)
Testing Functions-lower case: hello
If a function returns something and you want it printed, you need to
then tell Python to print the return. Please note that "return" and
"print" aren't the same things, return returns a given variable or
constant, and print simply prints a given variable or constant.
More information about the Python-list
mailing list