Created
March 2, 2021 12:57
-
-
Save ofelix03/e2db3fa0ec1341d370e1f3af1e7742e3 to your computer and use it in GitHub Desktop.
String concatenation using the Str.format()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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