Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python f strings

'''
In python, rather than adding pieces of string together, you can use
f-strings to insert variables into strings. This makes your code much
more easier to read.
'''

# OLD - WITHOUT F-STRINGS
name = 'Bob'
age = 12
print('This is ' + name + ', he is ' + age + ' years old.')

# NEW - WITH F-STRINGS
print(f'This is {name}, he is {age} years old') # Note the f in front
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #python #strings
ADD COMMENT
Topic
Name
1+2 =