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 trialpeter keves
6,854 PointsI'm not sure if i missed something in the last video but why did we use .title() in color property
I'm not sure if i missed something in the last video but why did we use .title() in color property
2 Answers
Martin Cornejo Saavedra
18,132 Points"The method title() returns a copy of the string in which first characters of all the words are capitalized." http://www.tutorialspoint.com/python/string_title.htm
a_string = "hello"
print(a_string.title())
#Hello
David McCarty
5,214 PointsEssentially, the .title() method is used to capitalize something.
You may be getting confused by his doing self.color.title(), but essentially what he's doing is calling the color attribute from the Monster class, and then the color attribute is getting capitalized with .title().
If he just did self.color it would return "blue"
But, if you do self.color.title() you get back "Blue"