Hello everyone! Quick question about Python. Halp?

Good day to all who read this!

I’m having an issue understanding this specific concept of string formatting in Python, and it’s use of the “%” symbol as an operator. Halp plz? All answers welcome, seriously.

Thank you for your time!


The % operator for string does a bunch of replacements, similar to how + for list will concatenate

Also, that’s no longer the recommended way to do string formatting, instead you’d write something like:

'{:.2f}'.format(57.1234)  # '57.12'

But either way, string formatting is like a small language of its own - figuring them out is what google and documentation is for