O
O
Olddd2021-09-10 16:51:42
Python
Olddd, 2021-09-10 16:51:42

Why is the class method not overridden?

class Note:
    def __init__(self, name, is_long=False):
        note = {'до': 'до-о', 'ре': 'ре-э', 'ми': 'ми-и',
                'фа': 'фа-а', 'соль': 'со-оль', 'ля': 'ля-а', 'си': 'си-и'}
        self.long = is_long
        if not is_long:
            self.name = name
        else:
            self.name = note[name]

    def play(self):
        print(self.name)

    def __str__(self):
        return self.name


class LoudNote(Note):
    def play(self):
        print(self.name.upper())


The LoudNote class should display the note in capital letters, but it doesn't, how can I fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
ZIK1337, 2021-09-10
@ZIK1337

prints in capital letters, how did you check?
snYfeTK.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question