我想做一个蟒蛇程序,其中20辆车随机更新每分钟的速度(现在设置为第二个)。它追踪他们驾驶的距离,并且首先赢得500英里。纳斯卡Python项目
但是,我当我运行它得到这个错误:
Traceback (most recent call last): File "E:\Python\NASCAR.py", line 3, in <module> class Car: File "E:\Python\NASCAR.py", line 10, in Car while miles < 500.00: TypeError: unorderable types: NoneType() < float()
我不知道如何解决这个错误,所以任何帮助表示赞赏。
import time
from random import randint
class Car:
miles = 0.00
carnumber = 0
#makes list of the cars, their speeds, and their distances. carspeed[1] is the same vehicle as cardistance[1] and "Jamie McMurray" under the Chip Ganassi Racing with Felix Stone team.
carspeed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
cardistance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Cars = {"Alex Bowman":"BK Racing", "Jamie McMurray":"Chip Ganassi Racing with Felix Sabates", "David Ragan":"Front Row Motorsports", "Martin Truex Jr":"Furniture Row Racing", "Casey Mears":"Germain Racing", "JJ Yeley":"Go FAS Racing", "Jeff Gordon":"Hendrick Motorsports", "Timmy Hill":"Hillman-Circle Sport LLC", "Justin Allgaier":"H Scott Motorsports", "Jor Nemechek":"Identity Ventures Racing", "Kyle Busch":"Joe Gibbs Racing", "A.J Allmendinger":"Bushs Baked Beans", "Alex Bowman":"R Pepper", "Aric Almirola":"Smithfield foods", "Austin Dillon":"Dow Chemicals", "Black Koch":"MDS", "Bobby Labonte":"Pheonix Racing", "Brad Keselowski":"Miller Lite", "Brett moffitt":"Land Castle Title", "Brian Keselowski":"BK Motors"}
while miles < 500.00:
time.sleep(1)
while carnumber != 19:
carspeed[carnumber] = randint(0,120)
print(carspeed)
cardistance[carnumber] += carspeed[carnumber]/60
carnumber += 1
mile = cardistance.sort
miles = mile()
print (miles)
什么是错误? – 2014-11-22 01:54:10
请给出回溯的**全文**,因为它会指出您发生问题的确切位置。 – MattDMo 2014-11-22 02:16:47