Skip to content

Instantly share code, notes, and snippets.

@rbricheno
Created August 5, 2020 10:53
Show Gist options
  • Save rbricheno/e4f7e5fb43edba92c182f8221bf1e5f6 to your computer and use it in GitHub Desktop.
Save rbricheno/e4f7e5fb43edba92c182f8221bf1e5f6 to your computer and use it in GitHub Desktop.
class CountedPerson:
counter = 0
def __init__(self, name):
self.name = name
print("Registered " + name)
CountedPerson.counter += 1
print("There are " + str(CountedPerson.counter) + " people registered.")
mike = CountedPerson("Michael")
gabe = CountedPerson("Gabriel")
print("There are " + str(CountedPerson.counter) + " people registered.")
# There are 0 people registered.
# Registered Michael
# Registered Gabriel
# There are 2 people registered.
@code-z2
Copy link

code-z2 commented Aug 5, 2020

Well explained
Thanks so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment