Program show error

what’s wrong in this code?


@mohdamaan2805 In python identation is everything because there are no braces or brackets for code. So you should write the following code in this manner:

Result of this is:
doubt1

Identation menas the code of if block should be one level deeper than the normal code, the code will clear your doubts :slight_smile:

Do close the query by clicking on the solution button

1 Like

You missed indentation in the code every line that’s part of the if or else statement should begin after some space so it all can be considered as part of one block and the subsequent lines after that can be written without spaces…
e.g
maths =“yes”
if maths == “yes”:
___print(“you will get toffee”)
else:
___print(“you will not get anything”)
print(“outside the conditional statement”)
The underscore is space since bolt forum is not showing spaces I have used underscore.

If you are using some conditions by using like loop,etc in Python , then INTENDETION is very important …you have to use INTENDENTION over evry if,elif statement

The problem is with inappropriate indentation, or lack of indentation to be precise.
All the codes that need to be executed if the condition is true must be indented rightwards. In your codes, you have not provided any statement to be executed if the maths == yes holds true.

It was an indentation error. The indentation error can occur when the spaces or tabs are not placed properly and u have to include brackets too.
So u have to write the above code as like
maths = “yes”
if(maths == “yes”):
print(“You will get toffee”)
else:
print(“You will not get anything”)
print(“Outside the conditional statement”)