6 Ways To Format A String In Python

Dr. Ashish Bamania
Level Up Coding
3 min readMar 15, 2023

--

Photo by Artturi Jalli on Unsplash

Let’s discuss the 6 ways to format a string in Python.

1. Using f-strings

One can include variables and expressions inside the curly braces {} inside a string, and these will be evaluated and replaced with their values when the program is run.

Check out the syntax below.

name = “Ashish” 
profession = "Doctor"…

--

--

Doctor 🩺 | Self-Taught Software Developer 👨‍💻 | Author 📘 | AIIMS, New Delhi 👨‍🎓 | Subscribe to my newsletter here: https://bytesurgery.substack.com/