Question

I would like to display a score with 7 digits. I tried to use string.format() in vain.

I have a score module and want to display like this : 0000000

My module add 10 points each time, so it has to be : 0000010 - 0000020 etc...

Any suggestion ?

Was it helpful?

Solution

Try this:

print(string.format("%07d", 10))

Output: 0000010

07 in the format specifier means use at least 7 digits, and fills them with leading 0s.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top