"Practice Makes Perfect"

<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/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

def cube(number):
if cube == cube.upper():
return “The cube of that number!”
def by_three(number)
if by_three == number.upper():
return “False!”

<do not remove the three backticks above>

Hi why do you use the method .upper()? its use to uppercase string …
you can read about it here
http://www.tutorialspoint.com/python/string_upper.htm

the lesson aske you to

1 First, def a function called cube that takes an argument called number. Don’t forget the parentheses and the colon!

2 Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again)

def cube(number):
     return number ** 3

or

def cube(number):
    return number * number * number

then

3 Define a second function called by_three that takes an argument called number.

def by_three(number):

4 if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False.

def by_three(number):
    if number % 3 == 0 :
        return cube(number)
    else:
        return False
7 Likes
 MY code still doesn't run correctly.  Please advise.

My code still doesn’t run correctly. Please advise.

can you post your code?

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

sorry If wasn’t clear but it should be like that

def cube(number):
    return number ** 3

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

this is a code that works, i took the liberty of adding my own touch, but the raw code is pretty simple. took me some time do solve this. really wanted to make a raw input for the number, but didn’t quite managed it, maybe I’ll learn in some other lesson.

def cube(number):
“”“Returns the cube of a number.”""
cubed = number**3
print “%s squared is %s.” % (number,cubed)
return cubed

cube(10)

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

1 Like

make sure you correct the code with TAB, would do it myself, but don’t really know how to do it (post the code in a square like you guys).

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

Why is this code not working .

Hi what error do you get?

File “python”, line 3
return numbernumbernumber
^
IndentationError: expected an indented block

Like the error says… IndentationError: expected an indented block so it should be like that

def cube(number):
    return number*number*number

Still not working!! and thanks for responding

Can you post your code and the error you get now?

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

Error:
File “python”, line 5
if number % 3 == 0:
^
IndentationError: expected an indented block

sorry

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

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

Actually return is not showing with spaces/indentation for some reason but there is space like you suggested.

here how to format your code