Python Idle not giving my prompt after If line
Terry Reedy
tjreedy at udel.edu
Mon Apr 9 13:18:46 EDT 2018
On 4/9/2018 3:07 AM, 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?
> 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
To enter 'else', instead of another line under 'if', hit backspace.
> That's why you have to hit <return> twice to trigger execution of the code.
When you are done entering the complete multiline statement.
> 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.
--
Terry Jan Reedy
More information about the Python-list
mailing list