[Tutor] variable in format string throwing error
Jim Mooney
cybervigilante at gmail.com
Mon May 13 23:51:51 CEST 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130513/64a21077/attachment.html>
More information about the Tutor
mailing list