0
class DetailedScore(Score):
'''A subclass of Score adding level'''

    def __init__(self, points, initials, level):
        '''
        (Score, int, str, int) -> NoneType

        Create a score including number of points, initials, and level.
        '''

        super().__init__(points, initials)
        self.level = level

    def __str__(self):
        '''
        Return a string representation of DetailedScore formated:

        'The student with initials 'KTH' scored 100 points, the student is in level 10'
        '''

        score_str = super().__str__()

        return '{}, the student is in level {}'.format(score_str, self.level)

    def __repr__(self):
        '''
        Return a string representation of DetailedScore formated:

        'DetailedScore(100, 'KTH', 10)'
        '''

        return 'DetailedScore({}, {}, {})'.format(self.points, self.initials, self.level)

score5 = DetailedScore(1000, 'JQP', 100)
score6 = DetailedScore(999, 'ABC', 99)
score7 = DetailedScore(999, 'BBB', 15)
score8 = DetailedScore(1, 'KTH', 12)

I am trying to finish this class, and am not sure why I keep getting an error when trying to build.

This is the error:

Traceback (most recent call last):
  File "/Users/KoryHershock/Documents/Python/[Kory_Hershock]_final.py", line 187, in <module>
    score5 = DetailedScore(1000, 'JQP', 100)
  File "/Users/KoryHershock/Documents/Python/[Kory_Hershock]_final.py", line 162, in __init__
    super().__init__(points, initials)
TypeError: super() takes at least 1 argument (0 given)
[Finished in 0.1s with exit code 1]

2 Answers 2

4

If you're using Python 2, you must write super(DetailedScore, self), not super().

It is Python 3 that also allows the no-argument form with the compiler inserting the appropriate class object taken from lexical context.

Sign up to request clarification or add additional context in comments.

2 Comments

I have python 3 installed on my computer, how would I make Sublime Text 2 run it? Or how would I run python 3 through terminal?
@KoryHershock The Python 3 executable is typically called python3. How to set it up in Sublime is probably best asked in a Sublime-related forum.
2

Change super().__whatever__() to super(Score, self).__whatever__()

1 Comment

Thanks for the reply, trying to run python3 which is installed on my computer, how would I make Sublime Text 2 run it? Or how would I run the program in terminal with python3?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.