简体   繁体   English

运行时错误:谁能帮帮我? Python代码

[英]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.

相关问题 谁能帮助我找出这段代码中的解析错误? - Can anyone help me figure out the parsing error in this code? 有没有人可以在这个 python 代码中帮助我? - is there anyone can help me in this python code? 谁能帮我解释这个python代码吗? - Can anyone help me explain this python code? 谁能帮我找出问题所在? 我的代码中出现索引错误 - Can anyone help me find out what's wrong? Index error in my code 我在 python 的 if -else 程序中遇到编译错误。代码是用 Python 3 编写的,谁能帮帮我 - I am getting compilation error in if -else program in python .The code is written in Python 3, can anyone help me 谁能帮我进行python网站抓取,下面是代码 - Can anyone help me with the python web scraping, below is the code 谁能帮我在我的 python GUI 代码中找到错误? - Can anyone help me to find mistake in my python GUI code? 谁能帮助我在此python代码中找到Cube - Can anyone help me in this python code for finding Cube 任何人都可以帮助我了解这部分 python 代码是什么意思吗? - Can anyone help me with what does this part of python code mean? 索引错误:列表索引超出范围。 谁能帮我解决这个 Python 代码? 包括 numpy 和 pandas 的概念 - IndexError: list index out of range. Can anyone help me out with this Python code ? Includes concepts of numpy and pandas
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM