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):
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.
I understand you are miscalculating and you wanted to enter 'No' in the next input for valetParking variable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.