Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ofelix03/e2db3fa0ec1341d370e1f3af1e7742e3 to your computer and use it in GitHub Desktop.
Save ofelix03/e2db3fa0ec1341d370e1f3af1e7742e3 to your computer and use it in GitHub Desktop.
String concatenation using the Str.format()
# Concatenation involving Str.format() strings
first_name = "Felix"
last_name = "Otoo
profession = "Software Engineer"
str_1 = "This is {first_name} {last_name}. ".format(first_name=first_name, last_name=last_name)
str_2 = "He is a {profession}. ".format(profession=profession)
str_3 = "He is from Ghana"
# Concatenating str_1, str_2 and str_3 using the plus(+) sign
str_4 = str_1 + str_2 + str_3
print(str_4) # Result: This is Felix Otoo. He is a Software Engineer. He is from Ghana"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment