Hello everyone! Quick question about Python. Halp?


#1

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!

https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/string-formatting-with--part--1?action=lesson_resume


#2

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