If I had the code:
names = ["Dave", "John", "Bob"]
and I wanted to get Dave from names I would do:
names[0]
If I now had the code
class Friends:
def __init__(self, *people):
self.names = []
for v in people:
self.names.append(v)
names = Friends("Dave", "John", "Bob")
to get Dave now I would have to do:
names.names[0]
Is there a magic method or something like that so that I can do:
names[0]
again and get Dave?