On 02/18/2013 11:42 AM, leonardo selmi wrote:
pls i need help:

i have copied the following from a book and tried to make it work:

import math

def area(radius):
return math.pi * radius**2

def circumference(radius):
return 2 * math.pi * radius

i saved the above program from python shell into a file as "circle.py" . when i type 
"import circle" i get  error..


kind regards

First, you shouldn't ask us to help you fix an error without telling us what the error is! You should also tell us what version of Python and what system (Windows? Linux? ...) , and anything more that can help us understand what you did and what failed.


So this is just guesswork:
Spaces are important in Python. The body of a function **must** be indented. If you do have the indents in your code, and they were just lost in the process of cutting and pasting and emailing, the we really do need more information.

def area(radius):
    return math.pi * radius**2

def circumference(radius):
    return 2 * math.pi * radius

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to