How to add to input time using timedelta | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to add to input time using timedelta

Im attempting to input a time, then distance, and speed. From that find the time traveled and add that to the departure time to get arrival time. I can't seem to find the proper format that doesn't give me an error. from datetime import date, datetime, time, timedelta #date_str=(input("date")) time_str=(input("time")) dist=int((input("distance"))) speed=int((input("speed"))) travel_time=dist//speed print(travel_time) arr_time=time_str+datetime.timedelta(hours=int(travel_time)) print(arr_time)

5th Jul 2020, 2:11 PM
Randall Ricks
Randall Ricks - avatar
1 Answer
0
Worked. Thank you. This datetime and timedelta just isn't clicking
5th Jul 2020, 2:45 PM
Randall Ricks
Randall Ricks - avatar