import locale and print range on same line

raiwil at gmail.com raiwil at gmail.com
Sat Jan 23 05:02:28 EST 2016


Can someone tell me why next code 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 --> indicating 'for'

However I need to put the code on one single line.
When I separate them like below 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