Practice make perfect. Need help



The reason you get that error is because when you ask the user for an input it is by default a string type and in python you cannot perform this operation


on strings.
To make it work you need to do this

n = int(raw_input())
n = raw_input()
return int(n)**3

I suggest that you get rid of the prompt in the cube method
But if you really wan to prompt the user then you might wanna do it in the second method and pass no arguments to it like this

def cube(n):
    return n**3
def cube_by_three():
    n =  int(raw_input("Enter number"))
    return cube(n) if n %3 ==0 else ""
print cube_by_three()

Note: this implementation is error prone. If user enters values other than numbers