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
Larz60+ write Aug-06-2022, 10:43 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
