Reputation: 2017
How I can fix it?
return 'loader:\n {}' % ''.join('{}:{}\n'.format(*(key, value) for key, value in slownik.iteritems()))
SyntaxError: invalid syntax
this should be in one line ;-)
Upvotes: 0
Views: 66
Reputation: 174624
'loader: \n '+''.join('{0}:{1}\n'.format(k,v) for k,v in slownik.iteritems())
Upvotes: 1
Reputation: 363547
Drop the '%', which is the old-style string formatter; drop the generator comprehension, because iteritems
returns exactly what you need to do formatting; finally, drop the double format
:
'loader:\n {0}:{1}\n'.format(*slownik.iteritems())
EDIT: ok, now I see what you want to do.
'loader:\n' + ''.join(' {0}:{1}\n'.format(k, v)
for k, v in slownik.iteritems())
Upvotes: 5