Exercise of python

3

In codeacademy, I'm having the error with the following code:

# Tenha certeza que the_flying_circus() retorna True
def the_flying_circus():
    if  5==5 :    # Comece seu codigo aqui!
    return True
        # Nao esqueca de recuar
        # o codigo dentro deste bloco!
    elif 5!=5 or 6>=4 :
    return False
    else: 
    return False
        # Continue aqui.
        # Voce vai querer adicionar tambem a declarao else!

Error:

  

Their setbacks seem a little strange. Read the Tip if you need   help!

    
asked by anonymous 07.08.2015 / 07:24

1 answer

7

The indentation in Python must be respected in order for the code to be executed in block perfectly.

Just add a tab or 4 espaços [1] on the lines that execute within the conditional structures:

def the_flying_circus():
    if  5==5:
        return True //identar
    elif 5!=5 or 6>=4:
        return False //identar
    else: 
        return False //identar

print the_flying_circus() //chamar função

I tested this code on codeacademy itself and it worked. You can test on pythonfiddle as well.

Indentation is a prevalent feature in Python language.

While code blocks are explicitly delimited in C , Java and PHP for keys, Pascal and Fortran for keywords as then and endif , in% are delimited by spaces or tabs forming a visual indentation, there are no symbols (in fact, the symbols themselves are the tabs themselves or spaces) that indicate when the code of a given function starts, or ends.

For this reason, Python requires a standardized indentation. In other languages, such as python or C/C++ , indentation is not required due to block delimiters, and is only used for better visualization.

    
07.08.2015 / 07:46