locale and for loop on same line
Bev in TX
countryone77 at gmail.com
Sat Jan 23 08:19:57 EST 2016
According to the documentation, "...simple statements may occur on a
single line separated by semicolons."
The "for" statement is a compound, not simple, statement.
Would it be possible to place your statements in a function and then you
would just need to invoke the function?
Bev in TX
On 1/23/16 4:08 AM, Ramo wrote:
> Can someone tell me why this doesn't work?
>
> import locale; locale.setlocale(locale.LC_ALL, ""); for i in range(1,20,4): print(locale.format("%2f", i, 1))
>
> It gives an error: SyntaxError: invalid syntax (highlighting the word 'for')
>
> I need this code on one and the same line.
> However when I separate them it works fine:
>
> import locale
> locale.setlocale(locale.LC_ALL, "")
> for i in range(1,20,4):
> print(locale.format("%2f", i, 1))
>
More information about the Python-list
mailing list