Skip to content

Instantly share code, notes, and snippets.

@ofelix03
Created March 2, 2021 13:41
Show Gist options
  • Save ofelix03/8f37ae5239cdb74c0f5676b1b9c4d65a to your computer and use it in GitHub Desktop.
Save ofelix03/8f37ae5239cdb74c0f5676b1b9c4d65a to your computer and use it in GitHub Desktop.
Concatenation involving f-strings
# Concatenation involving f-strings
#
# Unlike %-formatting and Str.format() examples above, we do not
# need the plus(+) sign
# or even evaluating and resolving final literal strings before
# joining them together
# We can achieve all of that with the f literal string.
str_1 = f"This is {first_name} {last_name}" f"He is a {profession}. " "He is from Ghana"
print(str_1) # 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