Function error

Discussion in 'Python' started by sandhyaranimangipudi@gmail.com, Jun 14, 2014.

  1. Guest

    I am new to python, pls help me to resolve the below error

    .... """Print a Fibonacci series up to n."""
    File "<stdin>", line 2
    """Print a Fibonacci series up to n."""
    ^
    IndentationError: expected an indented block
     
    , Jun 14, 2014
    #1
    1. Advertisements

  2. John Ladasky Guest

    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()
     
    John Ladasky, Jun 14, 2014
    #2
    1. Advertisements

  3. Terry Reedy Guest

    Please read the nice tutorial, though no necessarily all at once. It
    explains things like this.
     
    Terry Reedy, Jun 14, 2014
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.