Python Forum

Full Version: New user/beginner needing help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have only just started to learn Python programming
and hope someone can help me out here please.

I have created the following but can't understand why
the function won't output anything. any help and advice is really appreciated.
Thanks in advance.

def funny_function("Clowns", "are", "funny"):
    print "The words created are: " + first_word + second_word + third_word
    return first_word + second_word + third_word

funny_function()
You are not doing anything with the returned value, so it's not needed
>>> def funny_function(first_word, second_word, third_word):
...     print("The words created are: {} {} {}".format(first_word, second_word, third_word))
...
>>> funny_function("Clowns", "are", "funny")
The words created are: Clowns are funny
>>>
To explain Larz's comment:
1- function def parameters need to be variables, that way they can be used inside the function.
2- The syntax of print is: https://docs.python.org/3/tutorial/inputoutput.html
3- return is used to send information to the caller, e.g. assignment: thisVar = getValue()
Big thanks to Larz60+ for the help with the code. Also another big thank you to IAMK for the explanation and link.