f-string print 1

f-string print

f_string = f'My Name is {name} and my age is {age}'

print(f_string)
print(F'My Name is {name} and my age is {age}')  # f and F are same

Here is what the above code is Doing:
1. The f in front of the string tells Python to “format” the string.
2. The curly braces {} are placeholders for where the variables will be formatted into the string.
3. The variables are placed inside the curly braces and the variable names are preceded by a letter “f”.
4. The variables are placed inside the curly braces and the variable names are preceded by a letter “F”.

Similar Posts