xxxxxxxxxx
The f or F in front of strings tells Python to look at the values inside {} and substitute them with the values of the variables if exist.
Example:
agent = 'James Bond'
num = 9
# old ways
print('{0} has {1} number '.format(agent, num))
# f-strings way
print(f'{agent} has {num} number')
xxxxxxxxxx
>>> import datetime
>>> name = 'Fred'
>>> age = 50
>>> anniversary = datetime.date(1991, 10, 12)
>>> f'My name is {name}, my age next year is {age+1}, my anniversary is {anniversary:%A, %B %d, %Y}.'
'My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991.'
>>> f'He said his name is {name!r}.'
"He said his name is 'Fred'."
xxxxxxxxxx
#takes age as input
age=input("Enter your age: ")
#prints the input of age with a formatted string
print(f'You are {age} years old!')