'Handling **kwargs in python as instance variables

I'm trying to finish a freeCodeCamp project with python, this is the link for the full description of the project

Probability Calculator

I’m not sure how to deal with the parameters they provide me hat = prob_calculator.Hat(blue=4, red=2, green=6) because they’re not strings and I can’t use the split method.

Here’s what I’ve tried

class Hat:

def __nit__(**kwargs):
  content = []
  for key, value in kwargs.items():
    content.append(key)

I keep getting this "TypeError: Hat() takes no arguments" message

Blockquote



Solution 1:[1]

thanks for the feedback, I did some research and this is how it's done

class Hat:

  def __init__(self,**kwargs):
    content = []
    for key in kwargs.items():
        content.append(key)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 iSMAiL