python how to use the .format code example
Example 1: python string format
string_a = "Hello"
string_b = "Cena"
print("{0}, John {1}"
.format(string_a, string_b))
print("{greeting}, John {last_name}"
.format(greeting=string_a, last_name=string_b))
Example 2: formatting in python
>>> name = "John"
>>> age = 19
>>> language = "python"
>>> print(f"{name} of age {age} programs in {language}")
John of age 19 programs in python
>>> print("%s of age %d programs in %s" %(name, age, language))
John of age 19 programs in python
>>> print("{} of age {} programs in {}".format(name, age, language))
John of age 19 programs in python
>>> print("{2} of age {1} programs in {0}".format(name, age, language))
python of age 19 programs in John