Python String Interpolation
Syntax
String interpolation in Python is achieved using formatted strings (f-strings) or the str.format() method.
# Using f-stringsname = "Alice"age = 30message = f"{name} is {age} years old."
# Using the str.format() methodmessage = "{} is {} years old.".format(name, age)Example
# Displaying user details using interpolationuser = "John"balance = 250.75print(f"Hello, {user}. Your account balance is ${balance:.2f}.")