Return statement throwing error


#1

Make sure that the_flying_circus() returns True

def the_flying_circus():
result="True"
if 1==1 :
return result
elif 2<3:
return result
Error is

File "python", line 5
return 'True'
^
IndentationError: unindent does not match any outer indentation level


#2

result="True"

Boolean values: True/ False
They go without quotes.
When you surround some text between quotes It becomes just another python data type known as String.

Also make sure your code is indented properly.
Indentation in Python


#3

Hello greentreemee
Thanks for your reply.
I tried without quotes
def the_flying_circus():
result=True
if 1==1 :
return result
elif 2<3:
return result

but again I am getting error

File "python", line 5
return result
^
IndentationError: unindent does not match any outer indentation level


#4

Your code is probably not indented (structured) properly.

Try this syntax.

def the_flying_circus():
    result=True
    if condition : 
        return something
    elif condition:
       return something

Also read about indentation from link.


#5

Hello

I hope my code is structured properly,I am looking for an answer for this



#6

https://www.codecademy.com/courses/python-beginner-BxUFN/4/1?curriculum_id=4f89dab3d788890003000096#


#7

It will link through my course page only.
I think you have to add else too.

Back to instructions..

Write an if statement in the_flying_circus(). It must include:

if, elif, and else statements;

At least one of and, or, or not;
A comparator (==, !=, <, <=, >, or >=);
Finally, the_flying_circus() must return True when evaluated.


#8

Hello

I added else also ,but still I am getting the same error

File "python", line 5
return result
^
IndentationError: unindent does not match any outer indentation level

My code

Make sure that the_flying_circus() returns True

def the_flying_circus():
result=True
if 1==1 :
return result
elif 2<3:
return result
else :
return False
# Keep going here.
# You'll want to add the else statement, too!


#9

Can you format it?
when you post a code,you will see something like this</> at top bar,select your code and use that,It will get formatted.


#10

def the_flying_circus():
result=True
if 1==1 :
return result
elif 2<3:
return result
else :
return FalsePreformatted text


#11

Read this link and format the code..


#12

You have not added any of this operator in your code?


#13

Hello,

Thank you so much, It is working now .That was a formatting issue.

Have a great day ahead !!


#14

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.