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 trialLynn Collins
10,080 PointsTrying to get it to recognize Double
Syntax error???
class Double(int):
def__new__(int)
self = int.__new__(self)
return self
2 Answers
Steven Parker
231,198 PointsThere's a few issues:
- there should be a space after the keyword "def"
- the instructions say that the "method should accept self and one argument"
- the method code lines need to be indented more than the "def" line
- the instructions say to "Convert the argument to an int and return it."
Lynn Collins
10,080 PointsYes, I don't understand why they insisted on using a special keyword like "int." I would have rather used something else more appropriate like maybe "init." Or anything along those lines
Steven Parker
231,198 PointsThe "int" specified with the class is necessary, and is the keyword. But the terms on the "def" line are parameter names that you choose. Avoiding keywords or common function names can prevent errors that can be hard to track down.
Lynn Collins
10,080 PointsLynn Collins
10,080 PointsI will try again
Lynn Collins
10,080 PointsLynn Collins
10,080 PointsAfter some serious "rubber ducking," here's what passed that challenge: def new(self, int): return int * 2 After some experimentation I found that int * 2 passed the third echelon of this code challenge! Seriously, thank you :)
Steven Parker
231,198 PointsSteven Parker
231,198 PointsCongratulations! But in future you might also want to avoid using a special keyword (like "int") as a variable name.