[Idle-dev] Problem with the latest version of Python on macOS

Beni Cherniavsky-Paskin beni.cherniavsky at gmail.com
Wed Jul 31 14:50:04 EDT 2019


It's not bad indentation.  If that were the problem, you'd get
`IndentationErrror`.
(The indention is good despite looking weird because the `>>> ` is not part
of the code - imagine your first `if` starting at colunn 0.)

The problem is that IDLE Shell window expects a single expression/statement
per prompt, and you gave it 2 separate `if` statements.
In many such cases python 3 will give clear "multiple statements" error,
but not here.
You can confirm this by changing second `if` to e.g. `elif` (which makes
them one statement) - that works for me.

Same syntax would be fine in a .py file editor window - most python scripts
contain many statements
It's just limitation of the Shell window - you should execute each
statement separately by pressing Enter (possibly twice).

Tip: if you do want to paste many statements together, put them all inside
an `if True:` block to turn them into 1 statement.
If the copied code was not indented, select all pasted code, press Ctrl+]
(aka Format -> Indent region - this menu is only visible in editor window
but the shortcut works in Shell window too).



On Wed, 31 Jul 2019, 20:59 Sara Mistral, <saramsrl at hotmail.com> wrote:

> Hello,
> I downloaded Python recently on my computer and I have some troubles
> making it work. It doesn’t allow me to make and if function and elif
> without the good indentation. I have the latest version of Python (3.7.4)
> and my mac is updated (macOS Mojave 10.14.5).
> As you can see in the picture, the “if” doesn’t align properly. I tried
> with else, elif, if, and every time I hit “send” it sends me to the wrong
> indentation.
> My dad needs this for his work and he’s trying to learn Python but sadly
> he is stuck.
> Thank you for your help.
> Best wishes,
> Sara
> [image: Image]
>
> _______________________________________________
> IDLE-dev mailing list
> IDLE-dev at python.org
> https://mail.python.org/mailman/listinfo/idle-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/idle-dev/attachments/20190731/2bfe087f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Image.png
Type: image/png
Size: 2451176 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/idle-dev/attachments/20190731/2bfe087f/attachment-0001.png>


More information about the IDLE-dev mailing list