Members numbered in the order they join
Write code · Medium · §11.4 Shared by all, owned by each
Write a member class Member. The class variable count is the number of members created so far, and it starts at 0.
When you create a member with Member(name), it adds 1 to count and stores the new value as that member's number, number. The first member created is number 1, and the second is number 2.
print(m) prints #, then the number, a space, and the name, as in #1 mina. str(m) is the same string.
Leave the five lines at the bottom as they are. Their output is graded too. Some grading tests also reset Member.count to 0 before creating members.
Starter code
class Member:
# Write the class variable count, __init__, and __str__ here
pass
a = Member("mina")
b = Member("jun")
print(a)
print(b)
print(Member.count)Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.