Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 String formatting difficulties
#1
Hi all,

I would like to ask, why the below code is valid,

def place_value(number): 
	return ("{:,.2f}".format(number)) 

print(place_value(1000000.006)) 
But below code is not valid?

def place_value(number): 
	return ("{:,8.2f}".format(number)) 

print(place_value(1000000.006)) 
Thanks!
Yoriz wrote Aug-09-2019, 11:34 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote

Top Page

Messages In This Thread
String formatting difficulties - by mmk1995 - Aug-09-2019, 10:33 AM
RE: String formatting difficulties - by wavic - Aug-09-2019, 10:57 AM
RE: String formatting difficulties - by DeaD_EyE - Aug-09-2019, 11:04 AM
RE: String formatting difficulties - by wavic - Aug-09-2019, 11:18 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  string formatting Uchikago 1 286 Jun-28-2019, 03:28 PM
Last Post: buran
  TypeError: not all arguments converted during string formatting RedSkeleton007 1 7,486 Jul-15-2018, 08:51 PM
Last Post: ichabod801
  formatting string and returning as geojson garynobles 12 2,085 Mar-06-2018, 05:02 PM
Last Post: garynobles
  Dynamic Formatting of String mikera1979 2 737 Feb-27-2018, 07:09 AM
Last Post: mikera1979
  I have difficulties to use Pyshark jeanapala 1 713 Nov-21-2017, 01:45 AM
Last Post: Larz60+
  python2 string formatting - old and new - different for unicode buran 1 1,207 May-16-2017, 10:13 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)