I have tried codes from 4-5 other forums but can't get the right code from anywhere.
Read the instructions carefully. You supposed to have two functions defined. One is cube and the other one should be by_three. In your code there is function cube and inside of it there is another function.
Separate those two functions and improve indents and it should work.
thanks a lot for answering. I have already found the answer but what you are saying is correct.