• Register

There is a function in strings to dynamically update them.


str_1 = “ {} lives in {} {}.” 

print(str_1.format(“Rahul”, “Bhopal”, “Madhya Pradesh”)) 

Output of the above code will be : 

 >>> Rahul lives in Bhopal Madhya Pradesh.

The format function’s parameters will be given to strings in the particular order in which they are supplied, like in the example “Rahul” will be given to the first {}, “Bhopal” will be given to second {}, and “Madhya Pradesh” to the last {}.


100 points