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 trialjames mchugh
6,234 PointsThis code runs and gives me the square of a number in workspaces, but not in the activity, there I get a EOF error
I get an EOF error when I run this in the activity, but not in the workspaces
def square(number):
return (number * number)
square_number = int(input("What number do you want to square? "))
squared_number = square(square_number)
result = squared_number
print(result)
1 Answer
Kirsten Smith
3,484 PointsFor task 1, you can get rid of all of your testing code, it is confusing the compiler.
james mchugh
6,234 Pointsjames mchugh
6,234 PointsI got through task 1 with just 2 or 3 lines of code. I'm getting errors on task 2.
Kirsten Smith
3,484 PointsKirsten Smith
3,484 Pointsfor task 2, you only need one line of code, there is no need to print a result or ask for an input, all you need to do is CALL the function, PASS IN the number 3, and ASSIGN the result to the variable 'result' all which can be done in one line of code.
james mchugh
6,234 Pointsjames mchugh
6,234 PointsThanks for making me think about it. Also I was confused about the 3 until you explained that I needed to pass the number 3 to the square function. The tip about only needing 1 more line of code was what made me start thinking. Thank you!