in windows calculator the digits get seperated in thousands as you type in the number , how can it be done in python ? thanks
fonzali
0
Light Poster
Recommended Answers
Jump to PostDo you already have some code for the calculator ? Are you using a GUI toolkit ?
Jump to PostI am guessing that you used the built-in
float
type for this, but given that you are dealing with currency, I would recommend using the decimal module for representing the monetary value instead, …
Jump to Post>>> value = 1000000000000 >>> n = "{:,}".format(value) >>> print(n) 1,000,000,000,000 >>> #Back to float >>> float(n.translate(None, ',')) 1000000000000.0
All 10 Replies
Gribouillis
1,391
Programming Explorer
Team Colleague
fonzali
0
Light Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
snippsat
661
Master Poster
fonzali
0
Light Poster
fonzali
0
Light Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
fonzali
0
Light Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
fonzali
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.