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
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!")
Project 11-2: Arrival Time Estimator Create a program that calculates the estimated duration of a trip in hours and minutes. This should include an estimated date/time of departure and an estimated date/time of arrival. Console Arrival Time Estimator Estimated date of departure (YYYY-MM-DD): 2016-11-23 Estimated time of departure (HH:MM AM/PM): 10:30 AM Enter miles: 200 Enter miles per hour: 65 Estimated travel time Hours: 3 Minutes: 5 Estimated date of arrival: 2016-11-23 Estimated time of arrival: 01:35 PM Continue? (y/n): y Estimated date of departure (YYYY-MM-DD): 2016-11-29 Estimated time of departure (HH:MM AM/PM) : 11:15 PM Enter miles: 500 Enter miles per hour: 80 Estimated travel time Hours: 6 Minutes: 20 Estimated date of arrival: 2016-11-30 Estimated time of arrival: 05:35 AM Continue? (y/n): n Bye! Specifications For the date/time of departure and arrival, the program should use the YYYY-MM-DD format for dates and the HH:MM AM/PM format for times. Remember date and time will be a str format when input. Has to be converted to datetime # get departure date/time dep_date_str=input("Estimated date of departure (YYYY-MM-DD): ") dep_time_str=input("Estimated time of departure (HH:MM AM/PM): ") # convert str to datetime dep_str = dep_date_str + " " + dep_time_str dep_datetime = datetime.strptime(dep_str, "%Y-%m-%d %I:%M %p") For the miles and miles per hour, the program should only accept integer entries like 200 and 65. Assume that the user will enter valid data.
Step by Step Solution
There are 3 Steps involved in it
It seems you have a couple of issues in your code Youre reassigning the datetime module with a strin... View full answer
Get step-by-step solutions from verified subject matter experts
