Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping Create a Function

How do I call my call my function

squaring.py
def square(number):
    return number * number

result = square("number")

print(result)

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Instead of the print() method you just need to call the function by specifying its name, followed by curly braces. Then you pass in the value that the function is expecting.

Remember when you declared the function like this def square(number): You passed in a variable which you used an argument for the function. number.

As you see the function returns the result of a calculation. All you have to do is provide the number and that is what happens in a function call.

square(5);

Perfect. You're awesome Jonathan