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 trialLori Miller
2,362 PointsDifferent Solution to OOP Vocabulary
class Treehouse:
product = str('coding courses')
def __init__(self, name):
self.name = name
def learn(self):
return (f'{self.name} is learning to code!')
my_treehouse = Treehouse()
my_treehouse.name = 'Lori'
print(learn(my_treehouse))
I was able to get the same output as Megan, but with different code. After looking at the solution, I realized that I didn't have to use the str
constructor, but the main thing I noticed was my lack of indentation. Ultimately, aside from the unneeded constructor, I'm wondering if my code would still be considered "Pythonic".
The importance of indentation in Python is something I still struggle to understand and I'm wondering if anyone has any resources that they could share.