class – member variable string gets treated as Tuple in Python
class – member variable string gets treated as Tuple in Python
In your __init__
, you have:
self.model = model,
self.color = color,
which is how you define a tuple. Change the lines to
self.model = model
self.color = color
without the comma:
>>> a = 2,
>>> a
(2,)
vs
>>> a = 2
>>> a
2
Youve got a comma after those attributes in your constructor function.
Remove them and youll get it without a tuple
class – member variable string gets treated as Tuple in Python
yes, you have to remove comma from instance variables. from self.model = model, to self.model = model
Nice to see, you are using Class variable concept,
condition
is class variable and self.model
, self.color
, self.mpg
are instance variables.