Re: Converting a float to a formatted outside of print command

2009-11-30 Thread stephen_b
On Nov 23, 3:17 pm, Dan Bishop wrote: > You meant: > > x = '%.1f' % y Thanks, I'm a dufus today. -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Vlastimil Brom
2009/11/23 stephen_b : > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y > -- > http://mail.python.org/mailman/listinfo/python-list Maybe '%.1f' % y ? hth vbr -- http://mail.python.org/mailman/listinfo/python-lis

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Philip Semanchuk
On Nov 23, 2009, at 4:15 PM, stephen_b wrote: I'd like to convert a list of floats to formatted strings. The following example raises a TypeError: y = 0.5 x = '.1f' % y You're missing a percent sign: x = '%.1f' % y or: print '%.1f' % 0.5 Hope this helps Philip -- http://mail.python.o

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Iuri
You forgot a % simbol in your string: y = 0.5 x = '*%*.1f' % y []s iurisilvio On Mon, Nov 23, 2009 at 7:15 PM, stephen_b wrote: > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y > -- > http://mail.python.org/mai

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Dan Bishop
On Nov 23, 3:15 pm, stephen_b wrote: > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y You meant: x = '%.1f' % y -- http://mail.python.org/mailman/listinfo/python-list