How to solve this problem in my Python program?
vehicle = input("Enter vehicle type(bike/car/truck): ")
distance = int(input("Enter the distance: "))
toll = 0
while distance > 0:
if vehicle == "bike":
toll = 2
elif vehicle == "car":
toll = 5
elif vehicle == "truck":
toll = 10
break
print("Total toll is: ", toll * distance)
I have this program to find the total toll for a vehicle. For now I only want to find toll if the vehicle is bike, car or truck but even if I enter any other vehicle, the program is asking me for distance before breaking out of the loop. And if I declare the distance after the loop then the program won't work. What is the solution for this?