Python Python Basics Functions and Looping Create a Function

Kim Raffield
Kim Raffield
276 Points

Understanding what it means to create a function that defines a single parameter

I seem to be stuck on https://teamtreehouse.com/library/python-basics-3/functions-and-looping/create-a-function

I've been re-watching the associated video just before this exercise, but I am not understanding how to create a function named square and assign it a single parameter named number.

In comparing it to the code from the previous exercise, I think my misunderstanding is not being able to translate what I did previously to this new exercise.

Any guidance on how to execute and fully understand this exercise is much appreciated.

squaring.py
def square(number)
 number = 5 * 5
    return square
adam n
adam n
57,278 Points
def func(param):
  pass

^ that's an example of a func w/ a parameter. You've mostly done that right. Your issue is moreso how to use the value pased into the func.

1 Answer

  • First, define the function heading. You got it right: it's def square(number). Just don't forget to put a colon after the closing parenthesis
  • The body is incorrect. The lines must be properly indented, and it should look like the following:
return number * number