[英]Runtime Error: Can anyone help me out? Python code
The following piece of code has some runtime error cannot seem to fix it.以下代码有一些运行时错误似乎无法修复。 Can anyone help?
任何人都可以帮忙吗?
if __name__ == "__main__":
no_of_parked_vehicles = int(input())
list_vehicles = {}
t = 0
for i in range(no_of_parked_vehicles):
vehicleSeq = int(input())
fourWheeler = input()
parkedFor = float(input())
valetParking = input()
t = t + 1
parked_vehicle = ParkedVehicle(vehicleSeq, fourWheeler, parkedFor, valetParking)
list_vehicles[t] = parked_vehicle
parking_lot = ParkingLot(list_vehicles)
lot_number = int(input())
temp = parking_lot.updateParkedStatus(lot_number)
charge = parking_lot.getParkingCharges(lot_number)
if temp == None:
print("Lot Number Invalid")
else:
print(temp[0], temp[1])
if charge == None:
print("Lot Number Invalid")
else:
print(charge)
**The error is: Traceback (most recent call last): **错误是:Traceback(最近一次调用最后一次):
File "Solution.py", line 47, in <module>
parkedFor = float(input())
ValueError: could not convert string to float: 'No'**
It seems that you are entering text 'No' in the console when you should be entering a float number for the variable parkedFor.当您应该为变量 parkedFor 输入浮点数时,您似乎在控制台中输入了文本“否”。
I understand you are miscalculating and you wanted to enter 'No' in the next input for valetParking variable.我了解您计算错误,您想在 valetParking 变量的下一个输入中输入“否”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.