# 7. Functions - Call and Response

#1

Good Afternoon, I would really appreciate some help. Can someone help me? I read others request of help and It should be good.

Thanks

this is my code and it should just work instead I get the error below. I am sure it's a silly mistake.

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

# Call the square function on line 9! Make sure to
# include the number 10 between the parentheses.
square(10)

error = Oops, try again. Did you remember to call square(10) on line 9?``````

#2

Your indentation is wrong - put `square(10)` at the start of the line, in-line with `def square(n):`.

#3

Thank you a lot. Is there any place where I can learn more about "indentation"? or is it possible install a tool for automatic indentation?

Correct solution:

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

# Call the square function on line 9! Make sure to
# include the number 10 between the parentheses.
square(10)``````

#4

Most Python IDEs will indent for you, but you need to 'unindent' from functions and loops yourself.

Indentation isn't really something for documentation, but you can read about it from the Python docs: https://docs.python.org/2.0/ref/indentation.html

It basically means that code working with a certain code block, like in a function or an if statement, is all in the same place. It's always one 'tab-space' away from being in-line with the function declaration or the if-condition, etc.
If it's not part of any condition or function or loop then it's at the start of the line as it doesn't need indenting. Python is very particular about its indentation and kinda cries if it doesn't like what you did.

Also, it may also be referred to as white-space.

Hope this helps! If it does, please mark this answer as the solution to help me out. Thanks

#5

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