OOP Question [ SOLVED ] | Sololearn: Learn to code for FREE!


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/24/2022 7:13:25 AM


5 Answers

New Answer


Comment line 32 and see..


Put all objects in the same list, loop through the list


glxy = [Galaxy('A'), Galaxy('B')] for g in glxy: print(g.name)


Jayakrishna🇮🇳 Thanks !! 😊


Lisa what do you mean by 'loop through the list'? Is it writing the index of objects??