Created
August 5, 2020 10:53
-
-
Save rbricheno/e4f7e5fb43edba92c182f8221bf1e5f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well explained
Thanks so much