On 13/05/2013 22:51, Jim Mooney wrote:
I'm trying variable substitution in a format string that looks like one
that works, but I get an error. What am I doing wrong? tks
x = 40
s = 'John flew to the {0:-^{x}} yesterday'
print(s.format('moon', x))
Error is builtins.KeyError: 'x'
--
Jim
Using over complicated modern string formatting? Stick with the old C
style % style and it's much easier. Contrary to popular belief it's not
going away :)
--
If you're using GoogleCrap™ please read this
http://wiki.python.org/moin/GoogleGroupsPython.
Mark Lawrence
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor