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

Anda Hewger
Anda Hewger
394 Points

I don't understand why my code isn't rig Anda Hewgerht

The error says "AssertionError: unexpectedly none"

squaring.py
def square(number):
    result = number * number
    return result
square(3)

2 Answers

Steven Parker
Steven Parker
231,269 Points

The whole message is: "Bummer: AssertionError: unexpectedly None : Make sure you create a new variable named result"

I agree that the first part of the error message is a bit confusing. But the second part has a good clue!

You're calling the function OK, but you're not doing the part of the instructions that said "create a new variable named result to store the value from the function call"

Gabriel Nunes
Gabriel Nunes
6,161 Points

Hi,

Your code is correct, but note that the variable name that was asked have no relationship at all with the names you choose to use for your variables inside your method definition. They just make sense inside the method.

Otherwise your just calling the method with the command square(3) and not assigning it to any variable as requested.