Last active
July 18, 2023 15:33
-
-
Save DevloperHS/5f882ab1a4895dc5144fd658717642a5 to your computer and use it in GitHub Desktop.
Add a thousand separator in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| num1 = 3_000_000_00 | |
| num2 = 3_0 | |
| result = num1*num2 | |
| print(result) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| num1 = 3_000_000_00 | |
| num2 = 3_0 | |
| result = num1*num2 | |
| print(result) # print without seperator | |
| # print code with , and _ as separator, default value - 3 digits | |
| print(f"{result:,}") | |
| print(f"{result:_}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment