Functions: Call and response help


#1



https://www.codecademy.com/courses/python-beginner-c7VZg/1/2?curriculum_id=4f89dab3d788890003000096#


File "python", line 9
square(10):
^
IndentationError: unindent does not match any outer indentation level

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: unindent does not match any outer indentation level (python, line 9)

I expected it to return the square of 10. I tried several different things but the code above is just the one I choose to submit. I don't understand what the instructions are asking me to do.


Replace this line with your code. 

  square(10):
    """Returns the square of 10"""
    squared = 10**2
    print "%d squared is %d." (10, squared)
    return squared


#2

Square(10) should be a function.

def square():

Replace the 10 in your argument with a variable n, and do that wherever you have 10 written.

def square(n):

Then you need to call your function at the end of your code.

square(10)

This way the code will work with any number, I can call square(985883740) at the end of the code and have it print it.


#3

thanks for your help but unfortunately I'm still stuck.

I tried replacing the 10s in my code with n but it looks just like the sample code and the error message says that I didn't call square(10) on line 9

Where do I call square(10) in the code


#4

def square(n):
    """Returns the square of a number."""
    squared = n**2
    print "%d squared is %d." % (n, squared)
    return squared
square(10)

The last line, square(10), executes(calls) the function.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.