0

Cancelling a booked ticket

Can anyone please share some code of how to cancel a booking in an airline but only permitted 2hrs before the flight. Thanks

4th Jun 2019, 1:57 PM
Zahin Enan
2 Antworten
+ 4
from datetime import datetime departure_time = datetime.fromisoformat('2019-06-04 18:30') now = datetime.today() diff_in_seconds = (departure_time - now).seconds if departure_time < now or diff_in_seconds < 2*60*60: # less than 2 h print('no way') else: # >= 2 h print('wellllll...') Feel free to do the rest on your own
4th Jun 2019, 2:16 PM
Anna
Anna - avatar
+ 2
Thanks for your help :)
5th Jun 2019, 10:27 PM
Zahin Enan