some problems for an introductory python test

Wolfram Hinderer wolfram.hinderer at googlemail.com
Wed Aug 11 13:10:27 EDT 2021



Am 11.08.2021 um 05:22 schrieb Terry Reedy:
> Python is a little looser about whitespace than one might expect from 
> reading 'normal' code when the result is unambiguous in that it cannot 
> really mean anything other than what it does.  Two other examples:
>
> >>> if3: print('yes!')
> yes!
> >>> [0]  [0]
> 0

Not sure what you mean here - is it a joke? The first looks like an if 
statement, but isn't. The missing space *does* make a difference. (Try 
"if0" instead.)

The second is normal indexing, which allows white space. I wouldn't 
consider that surprising, but maybe I should? (Honest question, I really 
don't know.)

-- 
Wolfram Hinderer


More information about the Python-list mailing list