Class vs Instance Attributes
Completed
Create Student with a class attribute count = 0 that increases every time a student is created. Read names, create a student for each, then print the count and the names.
Input
One line of names.
Output
Two lines: the count, then the names.
Example
Input
ann bob cy
Output
3 ann bob cy
Editor
Python
Hints
A class attribute is shared by all instances.
Update it through the class: Student.count += 1.
Solution explanation
Writing self.count += 1 would create a separate instance attribute instead.
Show solution
class Student:
count = 0
def __init__(self, name):
self.name = name
Student.count += 1
students = [Student(n) for n in input().split()]
print(Student.count)
print(*[s.name for s in students])