I'm building car parking system and I'm having some issues with comparing time. Let's say "John" should pay 5$ for one hour to park his car. John leaves his car for 3:30 hours in parking lot and makes a payment when the time for the parking stops at 3:33. So what I would like to get here is something like this, but the thing is that its non logical to make an if at each hour. What's the way to somehow just count the sum of the payment to calculate. Also what I didn't mention is that 3:33 is more then half hour so we can count another hour. But what I want to do here is that:
I don't need to create much if's for parking to calculate the sum, that JOHN has to pay.
How to automaticly add an 5$ to the hours, that John stayed in the parking?
My code:
if Parking_Sum > datetime.timedelta(minutes=30):
print ("You were parking for more then 30MINS You have to pay 5$")
Price = 5
elif Parking_Sum > datetime.timedelta(hours=1):
print ("You were parking for more then hour You have to pay 10$")
Price = 10
elif Parking_Sum > datetime.timedelta(days=1):
print ("You were parking for more then DAY You have to pay 120$")
Price = 120