str.Format ()
# Python3 program to demonstrate
# the str.format() method
# using format option in a simple string
print("{}, A computer science portal for geeks."
.format("GeeksforGeeks"))
# using format option for a
# value stored in a variable
str = "This article is written in {}"
print(str.format("Python"))
# formatting a string using a numeric constant
print("Hello, I am {} years old !".format(18))
OUTPUT:
GeeksforGeeks, A computer science portal for geeks.
This article is written in Python
Hello, I am 18 years old!
Happy Hamerkop