I hoping someone can help with this.
I have created a class with a function in it that counts the total cars in 4 lists of cars.
On another script I am creating the interface and want to say if the answer to 'totalCars' is bigger than zero then proceed to offer a type of car.
However when I do this I get this error: TypeError: '>' not supported between instances of 'method' and 'int'. Here is the code:
def totalCars(self):
p = len(self.getPetrolCars())
e = len(self.getElectricCars())
d = len(self.getDieselCars())
h = len(self.getHybridCars())
totalCars = int(p) + int(e) + int(d) + int(h)
return totalCars
And on the interface script have:
while self.totalCars > 0:
To get around this I tried to use a boolean, like this:
def totalCars(self):
p = len(self.getPetrolCars())
e = len(self.getElectricCars())
d = len(self.getDieselCars())
h = len(self.getHybridCars())
totalCars = int(p) + int(e) + int(d) + int(h)
if totalCars > 0:
return True
And on the app script I have:
while self.totalCars is True
But this totally crashed the program and won't run at all.
Any guidance welcome here. Many thanks.