':10d' in f string

On this page

about 2/3rds of the way down, is this:-

print(f"{team:10} ==> {score:10d}")

I get that :10 means ‘up to 10 chararcters long’, and the article tells me that the 'd’means digit.

Are there any other characters like ‘d’? Ie something that specifies what type of character to put somewhere? It doesn’t appear to be regex. I’d look it up, but I don’t know what its called, and ‘python d’ doesn’t sound like a very effective search term.


There’s a lot about this in documentation, including some examples further on the page.

Thanks, yes, a lot to chew on there!

So ‘d’ here is a presentation type. I found the charts for decimal and float presentation types. It all looks like a bit of a rabbit hole at the minute, I think I need to take the time to properly learn about string formatting.

Can you recommend any good learning materials for that? Preferably with example projects to work on and check?

I don’t have any specific resources with exercises. Two projects in Scientific Computing with Python Projects have some occasions for playing around with various formatting: Arithmetic Formatter and Budget App.

Thanks, just started on budget.py yesterday, hence the need to learn more about f strings.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.