3000 explained code solutions for 75 technologies


pythonHow to insert variable into string


var = '10'
str = f'number is {var}'ctrl + c
var = '10'

declare test variable to insert into string

str =

resulting string with inserted variable

f'

tells python that we're going to insert some variables in this string

{var}

name of the variable to insert (between { and })