6. practice makes perfect



I entered the code and it raised an error that I do not understand! Any help would by highly appreciated!

The code is as follows:

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

And the error raised is as follows:

File "python", line 3
def by_three(number):
IndentationError: expected an indented block

As I said, any help would be highly appreciated.

6. 'Practice Makes Perfect'

your cube can not be empty:

def cube(number):
   # function can't be emptied!


The problem is clearly specified by the python interpreter here. IndentationError means the key TAB should be pressed. Here, a tab key must be pressed before

This is a very important concept in python. If you give a TAB after : in the next line, it means that whatever you are going to type next will be under the function or whatever it is.

For example:

 for i in range(2):
...     print "hai"

Here, if i did not give a TAB before the print statement, it will not be under the loop, it will just be another line of ordinary code and there would be nothing inside the for loop. So, it gives an error.

I hope you really understood what all this indentation is about.



The main thing is that your function is empty. However, if you ever did want to create a function as a placeholder for whatever reason, you could used the pass command. Something like this:

def blankFunction (temp):