in a string how to insert an variable value python code example
Example 1: insert value in string python
>>> shepherd = "Martha"
>>> age = 34
>>> # Note f before first quote of string
>>> stuff_in_string = f"Shepherd {shepherd} is {age} years old."
>>> print(stuff_in_string)
Shepherd Martha is 34 years old.
Example 2: embed variables python
#Pre 3.6
print('Hi, my name is {name} and my age is {age}'.format(**locals()))
#After 3.6
print('Hi, my name is {name} and my age is {age}')