Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types String Formatting

Alma Cuevas
Alma Cuevas
2,703 Points

How to use formats

The error says Task one can't be found

strings.py
name = "Henrique"
subject = "Treehouse loves {}" 
Treehouse_loves.format(name)

1 Answer

name = "Henrique"
subject = "Treehouse loves {}" 
#Treehouse_loves.format(name)
#here you probably meant, Treehouse_loves is not defined and
subject.format(name)

But thats not the correct answer either...

name = "Henrique"
#This is what author wants in particular
subject = "Treehouse loves {}".format(name)
#Treehouse_loves.format(name)
#here you probably meant
#subject = subject

format function is defined on string class.

Now string could be a string object saved in a variable or a string itself.

  • string objec would be: sample_string_object = "Soe string in here"
  • string: "This is a string."

Now to call a function/method defined for string class...

  • sample_string_object.function_name(arg1, arg2)
  • "This is a string.".function_name()