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 Collections (2016, retired 2019) Tuples Stringcases

Challenge is particular about which str method you use

Wondering why I couldn't pass the challenge using .capitalize()

Once I swapped .capitalize() with .title() in my code, I was able to complete the challenge. Why didn't it let me use .capitalize() when it returns the same thing?

1 Answer

Actually they don't return the same result. capitalize() returns the string with only the very first letter capitalized. title() returns the string with the first letter in each word capitalized.

E. g.

"testing both methods".title() 
  > "Testing Both Methods"
"testing both methods".capitalize()
  > "Testing both methods"

Ahhh, is see. That makes sense now.

Thanks