Re: [Tutor] variable in format string throwing error

2013-05-13 Thread Mark Lawrence
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

Re: [Tutor] variable in format string throwing error

2013-05-13 Thread eryksun
On Mon, May 13, 2013 at 5:51 PM, 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.KeyEr

[Tutor] variable in format string throwing error

2013-05-13 Thread Jim Mooney
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 ___