Created
March 2, 2021 13:41
-
-
Save ofelix03/8f37ae5239cdb74c0f5676b1b9c4d65a to your computer and use it in GitHub Desktop.
Concatenation involving f-strings
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 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