Function error

John Ladasky john_ladasky at sbcglobal.net
Sat Jun 14 14:25:18 EDT 2014


On Saturday, June 14, 2014 11:17:50 AM UTC-7, sandhyaran... at gmail.com wrote:
> I am new to python, pls help me to resolve the below error
> 
> 
> 
> 
> 
> >>> def fib(n):
> 
> ... """Print a Fibonacci series up to n."""
> 
>   File "<stdin>", line 2
> 
>     """Print a Fibonacci series up to n."""
> 
>                                           ^
> 
> IndentationError: expected an indented block

Python uses indentation to delineate blocks of code, instead of (for example) curly brackets.  Add some white space (the convention is four characters) after at least the first line that ends with a colon, and then indent every line that is in the code block accordingly.  Like this:

def fib(n):
    """Print a Fibonacci series up to n."""
    do_something()
    do_something_else()



More information about the Python-list mailing list