Python Idle not giving my prompt after If line

brgrt2 at gmail.com brgrt2 at gmail.com
Mon Apr 9 12:06:37 EDT 2018


On Monday, April 9, 2018 at 3:08:28 AM UTC-4, Peter Otten wrote:
> brgrt2 at gmail.com wrote:
> 
> > I typed the If part of an If/Else statement, but did not get a prompt at
> > the beginning of the next line when I hit return. Instead, the cursor
> > lined up under the "p" of "print." Here is the line of text (it's part of
> > a longer bit of coding, I copied out of a textbook).
> > 
> >>>> if right_this_minute in odds:
> >        print("This minute seems a little odd.")    [Return]
> > 
> > You can't see it, but the cursor is blinking under the "p."
> > 
> > Why is this happening and what's the fix?
> > 
> > Thanks,
> > 
> > Tamara
> 
> It works as designed; the interpreter has no way of knowing whether you are 
> about to write another line belonging to the if suite, like in
> 
> if foo:
>    print("clearing foo")
>    foo = False
> 
> That's why you have to hit <return> twice to trigger execution of the code.
> 
> By the way, when you copy (or write) a "longer bit" I recomend that you put 
> the code into a py file so that you don't have to retype it when you want to 
> make a small modification. Instead you can just hit F5 and see the effect of 
> your changes.

Thanks, Peter, for your quick reply. But here's what happened. When I hit <return> twice, the cursor did go back to the margin, but skipped two lines before doing so. Then when I hit <return> after "else:" I got an error message again. What did I do wrong? 
Also, could you please tell me how to create a py file. Thanks.



More information about the Python-list mailing list