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 trialSohail Mirza
Python Web Development Techdegree Student 5,158 PointsHow to create a function for the following
In the question section this question was given. How would i convert this into a function Could someone please provide an answer to this Thanks in advance
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))
2 Answers
Sohail Mirza
Python Web Development Techdegree Student 5,158 PointsHi Berend
Thank you very much for your response
Regards Sohail Mirza
berend folkers
950 Pointsdef squared(number): number_squared = number * number result = "The number {} is squared {}".format(number, number_squared) print(result)
squared(5) squared(8)
berend folkers
950 Pointsyou may have to restyle in de editer again. (I dont know how to copy past it proparly)