Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class Problem
#1
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?
Reply


Messages In This Thread
Class Problem - by scratchmyhead - Nov-19-2019, 02:40 AM
RE: Class Problem - by Larz60+ - Nov-19-2019, 04:39 AM
RE: Class Problem - by scratchmyhead - Nov-19-2019, 06:00 AM
RE: Class Problem - by Larz60+ - Nov-19-2019, 08:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Practice problem using lambda inside the class jagasrik 3 2,109 Sep-12-2020, 03:18 PM
Last Post: deanhystad
  [split] Python Class Problem astral_travel 12 4,857 Apr-29-2020, 07:13 PM
Last Post: michael1789
  Python Class Problem JPCrosby 2 2,232 Apr-28-2020, 06:18 PM
Last Post: buran
  Class problem duckduck23 2 1,977 Feb-10-2020, 08:52 PM
Last Post: jefsummers
  Class code problem from CS Dojo YouTube Dixon 3 2,219 Feb-04-2020, 10:23 PM
Last Post: snippsat
  problem with class method AmirAB 3 3,333 Feb-13-2019, 01:51 AM
Last Post: AmirAB
  A problem with child class Truman 2 2,739 Jul-02-2018, 12:37 AM
Last Post: ichabod801
  problem with simple class code diegoraffo 5 3,618 Jan-27-2018, 02:31 AM
Last Post: ka06059

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020