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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Liam White](https://secure.gravatar.com/avatar/4e431224b42de2d34f38ec7bb2c9b560?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Liam White
1,969 PointsPlease shed some light on how one would create a function on this quiz question...
Below is one of the quiz questions and it made sense for me as for the answer, but I got stuck on how I would make this a function. How would you create this code as a function so one wouldn't repeat the code?
first_number = 5 first_result = first_number * first_number print("The number {} squared is {}".format(first_number, first_result))
second_number = 8 second_result = second_number * second_number print("The number {} squared is {}".format(second_number, second_result))
3 Answers
![boi](https://uploads.teamtreehouse.com/production/profile-photos/10720541/micro_Kratos.jpg)
boi
14,242 PointsYou're currently on "Returning values" video right?. Just after this video is a challenge to create a function that would take any number and return the square of it. So basically the question you asked here, you will answer yourself once you solve that challenge.
If I help you by providing a solution to the question you asked, it would mean I solved the challenge for you. I recommend you try to solve the challenge, If you need help, I'll always be there to 🔦 shed some light 🔦
![Asad Amir](https://secure.gravatar.com/avatar/e5734bb6b002d777403bf0d48a6e305b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Asad Amir
Data Analysis Techdegree Student 474 Pointscan somebody please right the def function to explain the statement well please thanks in advance
![urus](https://secure.gravatar.com/avatar/035117e4f43c37377451f826cc4f8f2d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
urus
610 PointsHi Liam. I was stuck for a moment on that challenge as well. It may be helpful to review the video in Variables and then Functions. Best hint I can give you is to keep it simple... and clean.
Liam White
1,969 PointsLiam White
1,969 PointsThank you! 🤜🤛 I’ll let you know if I need any help after I complete that challenge.