Python Python Basics (2015) Python Data Types String Formatting

subject= "Tree house loves {}".format("name") does anyone know why this won't work?!!

Subject= "Tree house loves {}".format("name")
name= 'Olivia'
subject= "Tree house loves {}".format("name")

1 Answer

Robert Ionut Muraru
Robert Ionut Muraru
5,361 Points

Hello Olivia,


name= 'Olivia'
subject= "Tree house loves {}".format(name)

You are using "name" which makes the script see name as a string and not the variable you want to use.