![]() |
New user/beginner needing help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: New user/beginner needing help (/thread-9575.html) |
New user/beginner needing help - oldDog - Apr-17-2018 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() RE: New user/beginner needing help - Larz60+ - Apr-17-2018 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 >>> RE: New user/beginner needing help - IAMK - Apr-17-2018 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()
RE: New user/beginner needing help - oldDog - Apr-17-2018 Big thanks to Larz60+ for the help with the code. Also another big thank you to IAMK for the explanation and link. |