0

I have been trying to make something like this:

class Numbers:
    def __init__(self,one,two):
        self.one = one
        self.two = two

numb_list = ["three","four"]

num = Numbers(i for i in numb_list)

but I get a TypeError. So, is there a way I can make a new class instance from a list, tuple or a dictionary?

Ch3steR
  • 20,090
  • 4
  • 28
  • 58

1 Answers1

1

You have to unpack them using * and pass them.

num = Numbers(*numb_list)
num.one
# 'three'
num.two
# 'four'
Ch3steR
  • 20,090
  • 4
  • 28
  • 58