Project 11-2: Arrival Time Estimator Receiving error str object has no attribute datetime when I am running
Question:
Project 11-2: Arrival Time Estimator
Receiving error "str" object has no attribute "datetime" when I am running my module. What have I missed? (screen shot of assignment followed by module commands) Thank you!
import datetime
from datetime import timedelta
print("Arrival Time Estimator")
#loop date/time
again = 'y'
while (again == 'y'):
date = input("Estimated date of departure (YYY-MM-DD): ")
time = input("Estimated time of departure (HH:MM AM/PM): ")
datetime = date+" "+time
departuredatetime = datetime.datetime.strptime(datetime, '%Y-%m=%d %I:%M %p')
#miles and speed
miles = int(input("Enter miles: "))
speed = int(input("Enter miles per hour: "))
#travel time
print("Estimated time travel")
hours = miles//speed
minutes = round((miles%speed)/speed*60)
#travel time
print("Hours: ", hours)
print("Minutes: ", minutes)
#arrival time
arrivaldatetime = departuredatetime + timedelta(hours=Hours, minutes=Minutes)
arrivaldate = arrivaldatetime.strftime('%Y-%m-%d')
arrivaltime = arr_datetime.strftime('%I:%M %p')
print("Estimated date of arrival: ",arrivaldatetime)
print("Estimated time of arrival: ",arrivaltime)
again = input("Continue? (y/n): ")
print("Bye!")
Research Methods For Business Students
ISBN: 9781292208787
8th Edition
Authors: Mark Saunders, Philip Lewis, Adrian Thornhill