Python Object-Oriented Python Advanced Objects Double

Bashir Orfani
Bashir Orfani
13,169 Points

Remove pass from the body

Remove pass from the body of the Double class. Define the new method. The new method should accept self and one argument. Convert the argument to an int and return it.

doubler.py
class Double(int):
    def __new__(self):
        self = int.__new__(self.)
        self = self[::-1]
        return self

4 Answers

Steven Parker
Steven Parker
207,980 Points

The task 2 instructions say "The new method should accept self and one argument.", but the code here accepts only "self". You need another parameter to accept the argument.

Then, once you have it, the rest of the instructions say "Convert the argument to an int and return it.". You won't need to do anything with "self".

Steven Parker
Steven Parker
207,980 Points
    def __new__(self):  # <-- how many arguments besides "self" will this take?
Steven Parker
Steven Parker
207,980 Points

If see that function taking an argument other than "self", what's the name of the parameter that will hold the argument?

Bashir Orfani
Bashir Orfani
13,169 Points

thank you Steven i got it.

Steven Parker
Steven Parker
207,980 Points

Bashir Orfani — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!