Create two widgets and read total
Input
Widget(), Widget(); Widget.get_total()
Output
2
After creating two Widget instances, the class attribute should be 2. Each Widget should have ids 1 and 2 respectively.
Full lesson preview
Practice using a class attribute to track how many instances of a class have been created.
Problem statement
Task
Examples
Input
Widget(), Widget(); Widget.get_total()
Output
2
After creating two Widget instances, the class attribute should be 2. Each Widget should have ids 1 and 2 respectively.
Input format
Output format
Constraints
Samples
Input
Widget(); Widget.get_total()
Output
1
One Widget created, total is 1.