初莫M 发表于 2023-11-22 19:37:59

SyntaxError: invalid syntax 错在哪了啊

cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
avergae_passengers_per_car = passengers / cars_driven


print("There are",cars,"cars available.")
print("There are only",drivers,"drivers available.")
print("There will be",cars_not_driven,"empty cars today.")
print("We can transport",carpool_capacity,"people today.")
print("We have",passengers,"to carpool today.")
print("We need to put about",avergae_passengers_per_car,"in each car.")

isdkz 发表于 2023-11-22 19:38:03

你的代码中有一个拼写错误。在最后一行代码中,"average_passengers_per_car" 被拼写为 "avergae_passengers_per_car"。将其更正为 "average_passengers_per_car" 后,代码将不再报错。

hellomyprogram 发表于 2023-11-22 20:03:39

你的代码没有问题——可以尝试上传一下完整代码或报错提示。
页: [1]
查看完整版本: SyntaxError: invalid syntax 错在哪了啊