Python Forum
New user/beginner needing help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New user/beginner needing help
#1
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()
Reply
#2
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
>>>
Reply
#3
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()
Reply
#4
Big thanks to Larz60+ for the help with the code. Also another big thank you to IAMK for the explanation and link.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  needing some help to write some code for a game calculator rymdaksel 1 393 Jan-02-2024, 09:56 AM
Last Post: deanhystad
  Needing to Check Every Quarter Hour bill_z 10 2,980 Feb-09-2022, 07:23 PM
Last Post: menator01
  Noob needing guidance.... bako 0 1,850 Mar-29-2020, 06:55 PM
Last Post: bako
  Global Variables - Some Points Needing Clarification. adt 4 2,948 Nov-30-2019, 01:23 PM
Last Post: adt
  Beginner needing advice with data files JFI2019 2 2,191 Nov-06-2019, 04:56 PM
Last Post: JFI2019
  Typical beginner needing some help foxter00 1 2,645 May-08-2019, 11:46 PM
Last Post: michalmonday
  Beginner user: mathematical operations Mahdi1994 1 2,836 Mar-19-2018, 11:07 AM
Last Post: Larz60+
  Beginner needing help! Franco 2 3,229 Jul-29-2017, 12:56 PM
Last Post: Franco

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020