I want to add or insert thousands commas in between digits of a number as long as I input digits like some calculators (see the image). For example, when I begin inputting the digits 793, the code inserts automatically a thousands comma if I input the forth digit say for example 5, hense the number looks like 7,935 and so forth. I have no idea, it seems difficult for me. You can show me with a variable, a text edit or anything else, and any help even small would be appreciated.
[enter image description here](https://phpout.com/wp-content/uploads/2023/08/rRR07-jpg.webp
Question posted in Xcode
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
2
Answers
You can format number on display like:
You can use Python’s built-in string formatting to achieve this. Here’s how you can insert thousands commas into a number.
When you run the code above, it will print 1,234,567,890. The format() function with the :, format specifier adds commas as thousands separators.