lundi 8 mars 2021

How to fix this python code about Boolean variables and if statements

The question:

Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guzzler line from model years 2004-2007. Given variables modelYear and modelName write a statement that assigns True to recalled if the values of modelYear and modelName match the recall details and assigns False otherwise.

The code :

if 1999 <= modelYear <= 2002 and modelName == "Extravangant":
    recalled = True
elif 2004 <= modelYear <= 2007 and modelName == "Guzzler":
    recalled = True
else:
    recalled = False

Can't figure out what is missing after checking other people's code.

Aucun commentaire:

Enregistrer un commentaire