I'm trying to write a string formatting demo, just for things like
%.4f, %.3e, and %.3g.
Here's what I have, but of course it doesn't work. What should the print
statement be?
x = raw_input("enter a float: ")
if x == "":
print "x will be the default 1234.56789"
Dick Moores said unto the world upon 2005-04-10 03:38:
I'm trying to write a string formatting demo, just for things like
%.4f, %.3e, and %.3g.
Here's what I have, but of course it doesn't work. What should the print
statement be?
x = raw_input("enter a float: ")
if x
Brian van den Broek said unto the world upon 2005-04-10 03:58:
Dick Moores said unto the world upon 2005-04-10 03:38:
I'm trying to write a string formatting demo, just for things like
%.4f, %.3e, and %.3g.
Here's what I have, but of course it doesn't work. What should the
print statement be?
Brian van den Broek wrote at 01:09 4/10/2005:
Hi Dick,
why not replace th last line with the following 2:
print_value = ('%' + s ) %x
print "%f formatted with '%s' is %s" %(x, s, print_value)
HTH,
Brian vdB
Sorry, half asleep: I should also have said that I don't think it is
wise to call your user