-
Notifications
You must be signed in to change notification settings - Fork 7
String formatting
Benjamin Loire edited this page Mar 30, 2023
·
1 revision
By convention, all strings should be in double quotes "" (single quotes will be blackened either way). If dynamic content is needed in a string, it should be formatted using f-strings like so:
foo = "bar"
baz = 5
print(f"The value of foo is {foo}, and baz is {baz}")About any operation can go in the brackets, however you will need to use single quotes if you need a string there.
foo = ["bar","baz"]
print(f"The elements in foo are {','.join(foo)}.")