Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

What is the use of f in python?

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')

OUTPUT:
James Bond has 9 number
Source by tutorial.eyehunts.com #
 
PREVIOUS NEXT
Tagged: #What
ADD COMMENT
Topic
Name
8+2 =