The indentation not working with if

I am learning Python and I wanted to do a one_way decision have a problem with the if statement when I indent after : it doesn’t act as a block it doesn’t even show the arrow to minimize the block like the else statement.

and in the command prompt when I run the script if I write 6 which is true 6 is greater than 5 and prints out line 8 but if I write 2 which is false it prints line 6,7,8

Everything is working correctly. i < 5 evaluates to true for i = 2 and false for i = 6 because < is the “less than” symbol. You don’t have an else statement, so the program will always run line 8.

Are you sure? It works for me. Have you tried moving the mouse over the line number next to the if?

yes I tried to hover the mouse no arrow here I wrote a different script with elif and else condition this way it work perfect the script but its weird the if still doesn’t recognize as a block no arrow beside it .

note the mouse doesn’t show on pic I used print screen

Try magicpython instead and see if that fixes it.

For sharing screenshots from Windows, there’s really no substitute for ShareX. It’s open-source and has tons of features built in. To get the following screenshot, I pressed ctrl-prtsc and dragged a selection box that has a microscope attached so you can get pixel-perfect cropping if you’re into that (I am), then the program automatically uploaded the image to a filesharing site and copied the URL to my clipboard.

just wanted to let you know I downloaded magicpython and it fixed it thanks

Good to know. :slight_smile:

print(“enter a value of greater than 5”)
sval=input(“value:”)
ival=int(sval)
if ival>5:
print(“value”,ival,“is greater”)
elif ival==5:
print(“value”,ival,“is equal not greater”)
else:
print(“value”,ival,“is lesser”)
print(“all done”)
RUN with Python 3.7.3shell, and i want to konw why you all coding python codes without python?

Clearly, the original poster has Python installed, since they were able to run their script.