 Fix source code for my Time Calculator Project in freeCodeCamp

Hello everybody, I finished project for Time Calculator in Python. My source codes is true, but it was error:

Here is my soure codes:
time_calculator.py

days_of_the_week_index = {"monday": 0, "tuesday": 1, "wednesday": 2, "thursday": 3, "friday": 4, "saturday": 5, "sunday": 6}

days_of_the_week_array = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

duration_tuple = duration.partition(":")
print(duration_tuple)
duration_hours = int(duration_tuple)
duration_minutes = int(duration_tuple)

start_tuple = start.partition(":")
start_minutes_tuple = start.tuple.partition(" ")
start_hours = int(start_tuple)
start_minutes = int(start_minutes_tuple)
am_or_pm = start_minutes_tuple
am_and_pm_flip = {"AM": "PM", "PM": "AM"}

amount_of_days = int(duration_hours / 24)

end_minutes = start_minutes + duration_minutes
if(end_minutes >= 60):
start_hours += 1
end_minutes = end_minutes % 60
amount_of_am_pm_flips = int((start_hours + duration_hours) / 12)
end_hours = (start_hours + duration_hours) % 12

end_minutes = end_minutes if end_minutes > 9 else "0" + str(end_minutes)
end_hours = end_hours = 12 if end_hours == 0 else end_hours
if(am_or_pm == "PM" and start_hours + (duration_hours % 12) >= 12):
amount_of_days += 1

am_or_pm = am_and_pm_flip[am_or_pm] if amount_of_am_pm_flips % 2 == 1 else am_or_pm

returnTime = str(end_hours) + ":" + str(end_minutes) + " " + am_or_pm
if(day_of_week):
day_of_week = day_of_week.lower()
index = int((days_of_the_week_index[day_of_week]) + amount_of_days) % 7
new_day = days_of_the_week_array[index]
returnTime += ", " + new_day

if(amount_of_days == 1):
return returnTime + " " + "(next day)"
elif(amount_of_days > 1):
return returnTime + " (" + str(amount_of_days) + " days later)"
return returnTime

File main.py

# This entrypoint file to be used in development. Start by reading README.md
from unittest import main

# Run unit tests automatically
main(module='test_module', exit=False)

Can somebody help to fix this error in my project for Time Calculator in Python ?

Here is my solution: https://replit.com/@quanganh2001/boilerplate-time-calculator#main.py
Thank you very much!

As the error suggests, take a closer look at the line 13 in time_calculator.py:

File "/home/runner/ELUtkiORl3o/time_calculator.py", line 13, in add_time
start_minutes_tuple = start.tuple.partition(" ")
AttributeError: 'str' object has no attribute 'tuple'
start_minutes_tuple = start.tuple.partition(" ")
1 Like

Thank you very much for your fixing code. I have substituted my source code already.