Aug-06-2022, 09:56 AM
Hi,
Is there a built in command that does that?
Thanks
# Code borrowed from geeksforgeeks.com class geeks: def __init__(self, name, roll): self.name = name self.roll = roll # creating list list = [] # appending instances to list list.append(geeks('Akash', 2)) list.append(geeks('Deependra', 40)) list.append(geeks('Reaper', 44)) # Is there a single instruction to do this? namelist = [] for obj in list: namelist.append(obj.name) print (namelist)The above traverses the object list to build a list of one of the parameters of this list.
Is there a built in command that does that?

Thanks