format string python3 code example
Example 1: python f string
>>> name = "Eric"
>>> age = 74
>>> f"Hello, {name}. You are {age}."
'Hello, Eric. You are 74.'
Example 2: str.format python 3
print("Sammy the {pr} {1} a {0}.".format("shark", "made", pr = "pull request"))
Example 3: python string format
print("My name is {0} and I am {1} years old".format(name, age))
Example 4: str.format python 3
print("Sammy ate {0:f} percent of a {1}!".format(75, "pizza"))