如何修复关于布尔变量和if语句的python代码

2024-05-14 09:28:19 发布

您现在位置:Python中文网/ 问答频道 /正文

问题是:

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.

守则:

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

无法在检查其他人的代码后找出缺少的内容


Tags: andinfromtruemodellineallits

热门问题