Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
class Fahrzeug:
    def __init__(self,Leergewicht:int,Baujahr:int):
        self.Leergewicht = Leergewicht
        self.Baujahr = Baujahr
        #self.Leistung = Leistung
    def __str__(self):
        pass


class Fahrrad(Fahrzeug):
    def __init__(self,Leergewicht,Baujahr,Rahmengröße):
        self.Rahmengröße = Rahmengröße
        super().__init__(Leergewicht,Baujahr)

    def __str__(self):
        #ord = "Fahrrad Leergewicht : {}kg Baujahr: {} Rahmengröße: {}cm"
        #return ord.format(Leergewicht,Baujahr,Rahmengröße)
        return  ('Fahrrad Leergewicht : ',Leergewicht)

rad = Fahrrad(10,2019,55)
print(rad)


What I have tried:

i defined the attribute Leergewicht but the raised error tells that the att(Leergewicht) is not defined.
why? how to fix it?
the code is written in german..
Posted
Updated 20-Jul-20 7:48am
Comments
[no name] 20-Jul-20 13:37pm    
See my answer I have no idea about Python. But about 10 Min. trials on Online Python Compiler (Interpreter)[^] and some google how to convert an int to string in Python:
return ('Fahrrad Leergewicht : ' + str(self.Leergewicht))

[Edit]
Must be less than 10 Min. You posted before 7 mins ;)

1 solution

I have no idea about Python. But about 10 Min. trials on Online Python Compiler (Interpreter)[^] and some google how to convert an int to string in Python I found this should do it:
return ('Fahrrad Leergewicht : ' + str(self.Leergewicht))
 
Share this answer
 
Comments
Ahmad Qassym 20-Jul-20 15:34pm    
thanx bro
[no name] 21-Jul-20 8:12am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900