String formatting is used to insert values into a string.

  • using comma
name = "xnocode"
age = 25
 
print("My name is", name, "and age is", age)

output

My name is xnocode and age is 25
  • using + operator
name = "xnocode"
 
print("Hello " + name)

Note

  • Works only with strings
  • Need type conversion for numbers