locale and for loop on same line

2016-01-23 Thread Ramo
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 separat

Re: import locale and print range on same line

2016-01-23 Thread Ramo
This works also but I thought it was possible to do it easier: import locale; locale.setlocale(locale.LC_ALL, ""); print('\n'.join(locale.format("%2f", i, 1) for i in range(1,20,4))) -- https://mail.python.org/mailman/listinfo/python-list

Re: import locale and print range on same line

2016-01-23 Thread Ramo
The reason why I want to have it on onto one line has nothing to do with my question, "why doesn't it work on one line" :) But if you want to know it, I use this python code in the commandline of a texteditor :) Btw.. thank you all for your help. Very happy with it :) -- https://mail.python.or