Python Forum

Full Version: Class Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am writing a python program exactly the way my course instructor has and when I try to run on my end, I get the following error: AttributeError: 'TagCloud' object has no attribute 'tags'

Below is the code:

class TagCloud:
    def __int__(self):
        self.tags = {}

    def add(self, tag):
        self.tags[tag] = self.tags.get(tag, 0) + 1

cloud = TagCloud()
cloud.add("Python")
cloud.add("Python")
cloud.add("Python")
print(cloud.tags)
What am I doing wrong?
line 2 should be:
    def __init__(self):
missing the i in init
Thank you for pointing that out. I feel really stupid. I guess I really need to watch my typing.
it happens to everyone from time to time