You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# We start the string with the keyword f, followed by our string in double quotes and {} is used as a placeholder for the values involved in the formatting.
# The following example makes it clearer:
name = "John"
age = 17
print(f"I am {name} and I am {age} years old")
# Output- I am John and I am 17 years old
# Note that F(in capitals) also works
# Using multi-line f-strings:
name = 'John'
age = 32
occupation = 'Web developer'
msg = (
f'Name: {name}\n'
f'Age: {age}\n'
f'Occupation: {occupation}'
)
print(msg)
# You can also write a multi-lines f-string with double quotes like docstrings: