0

I have an class:

class Competitor(object):
      def __init__(self, name):
          self.name = name

I have an array of names:

names = ["john", "micheal", "adam"]

How can I run through this array and instantiate a Competitor with the same name in this array? So at the end I would like Competitor objects john, micheal and adam.

Will this work: trying to create a dict

hackers = {}
for name in names:
    hackers[name] = Competitor(name)

P.S. I tried looking through other questions but I didn't understand what they were trying to do/ wasn't sure if it was the same problem I had.

Username
  • 1,950
  • 2
  • 12
  • 21

0 Answers0