DEV Community

Discussion on: Formatting strings in Python

Collapse
lukaszahradnik profile image
Lukáš Zahradník • Edited on

Hi, look into f-strings (python.org/dev/peps/pep-0498/) if you want formatting like templates in javascript.

You can simply format string in python like this:

name = "Chris"
age = 32
text = f"His name is {name}, {name} is {age} years old"
print(text)

Enter fullscreen mode Exit fullscreen mode
Collapse
dailydevtips1 profile image
Chris Bongers Author

Hi Lukas! Indeed these look super powerful, will write another article on f-strings