Practice makes perfect


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/functions/exercises/practice-makes-perfect?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
File “python”, line 5
return cube(number)
^
IndentationError: expected an indented block

<What do you expect to happen instead?>

```python

def cube(number):
return number**3
def by_three(number):
if number%3 == 0:
return cube(number)
else:
return False

<do not remove the three backticks above>

#2

Python is fussy about indentation. It’s how code blocks are defined, i.e. by nested lines of code at different levels of indentation.

For your code, make sure that it’s indented as follows:

def cube(number):
    return number ** 3

def by_three(number):
    if number % 3 == 0:
        return cube(number)
    else:
        return False

Tip: If the indenting looks right to you but you are still getting the IndentationError, try this:

  1. Put your cursor at the start of the line that is the error message is told you is the problem. In your code that would be before the return cube(number).
  2. Then delete the whitespace until that line is inline with the one before it.
  3. Then press enter.

The editor indents it for you.

Cheers


Help me with 12. Stocking out
#3

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