Samuel
asked

Expert
Kelish Rai answered
F-strings are important in Python because they make it easier and cleaner to format strings.
For example, instead of formatting the output with the + operator like this:
firstName = "John"
lastName = "Doe"
print("My name is " + firstName + " " + lastName)
You can simply do this:
firstName = "John"
lastName = "Doe"
print(f"My name is {firstName} {lastName}")
As you can see, it's much easier to format the strings using f-strings than using string concatenation.
Python
This question was asked as part of the Getting started with Python course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer