Answers for "count variable in class python"

-1

count variable in class python

class Car:
  counter = 0
  def __init__(self,color):
    self.color = color
   	Car.counter += 1

car1 = Car("red")
car2 = Car("orange")
print(Car.counter)
Posted by: Guest on October-04-2020

Code answers related to "count variable in class python"

Python Answers by Framework

Browse Popular Code Answers by Language