Code: Alles auswählen
Code: Alles auswählen
def __init__ (self,a,b):
self.ws=[]
for i in range (1,b+1):
self.ws.append(a*i)
def __str__(self):
return "Lösung:" + str(self.ws)
class B:
def __init__ (self,n,m):
self.a=[]
z=n+1
while n > 0 :
self.a.append(A(z-n,m))
n -=1
def __str__(self):
return "Ergebnis: " + str(self.a)
#Hauptprogramm
p=3
q=4
b33 = B(p,q)
print(b33)
Die Liste der Klasse a wird gut lesbar ausgegeben, allerdings kommt bei der Ausgabe der Klasse b nur folgendes Ergebnis:Ergebnis: [<__main__.A object at 0x000000D6E8297358>, <__main__.A object at 0x000000D6E8297390>, <__main__.A object at 0x000000D6E82973C8>]
Weiß jemand, was ich ändern muss, damit auch B wie A vernünftig lesbar ausgegeben wird?
Danke schon mal im Voraus