1

I have been learning Python programming from a book and I came across a sentence which I can't understand!

When you enter this code in the IDLE, it will automatically indent, so be sure to press the backspace or delete key once you’ve typed each print statement, so that your if, elif, and else statements will start at the far-left margin. This is the same position the if statement would be in if the prompt (>>>) were absent.

I just don't get this part:

This is the same position the if statement would be in if the prompt (>>>) were absent.

What does "would be in" mean?

4
  • 1
    I edited your question to help others understand what you were asking. If you feel the edits were incorrect feel free to revert them.
    – MrHen
    Oct 19, 2013 at 16:38
  • @MrHen Well done Mr Hen. But I think we could achieve even more clarity with some punctuation. Try 'This is the same position the 'if statement' would be in, if the prompt...were absent.'
    – WS2
    Oct 19, 2013 at 16:53
  • @WS2: I assumed the quoted portion was copied verbatim and did not edit it.
    – MrHen
    Oct 19, 2013 at 17:38
  • @MrHen Thank you MrHen,it's perfect.sorry if i bothered you,i'm just a newbie there.
    – The_Diver
    Oct 19, 2013 at 23:14

1 Answer 1

2

I text talks about a case like the following

if x:
   print("Hello")
else:
   print("Goodbye")

That's the correct way to format. Wrong would be:

if x:
   print("Hello")
   else:
       print("Goodbye")

To prevent the wrong way from happening you have to hit the delete key after you wrote print("Hello") and pressed <Enter>.

What's with the prompt? If you are in IDLE the correct text will look like:

>>> if x:
        print("hello")
else:
        print("goodbye")

The sentence says that if would be at the same height as else if the >>> wouldn't be there. As far as python is concerned if and else are on the same level on indention.

4
  • Oh Thanks! i just don't know how to appreciate you! i got the meaning of concept.you really helped me,thank you very much.
    – The_Diver
    Oct 19, 2013 at 23:07
  • 1
    @The_Diver: If the answer is what you were looking for you can check it as accepted. :)
    – MrHen
    Oct 19, 2013 at 23:29
  • @MrHen How do i do that?
    – The_Diver
    Oct 20, 2013 at 1:58
  • 1
    Click on the green arrow to the left of the answer, just underneath the up/down arrows. Oct 20, 2013 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.