+ 2
OOP Question [ SOLVED ]
I have a code with a class and many objects created from it. There are many objects and I want to print them altogether using a function. Can anybody tell me how can this be done?? Here's that code: https://code.sololearn.com/cU7TI6AjVY09/?ref=app First there is a function dec() for printing a line, next is info() to print the parameters and after that is call() to call the both functions above. But using call() I have to call the function as many times as the objects. So I want to create a function that includes call() and prints all the objects as well.
5 odpowiedzi
+ 3
Comment line 32 and see..
+ 4
Put all objects in the same list, loop through the list
+ 3
glxy = [Galaxy('A'), Galaxy('B')]
for g in glxy:
print(g.name)
+ 3
Jayakrishna🇮🇳 Thanks !! 😊
+ 1
Lisa what do you mean by 'loop through the list'?
Is it writing the index of objects??