Basta Fazoolin' Project help

Basta Fazoolin’ Project help. I need help in making the repr dunder method change the militarty time to regular time. It just gives military time in the project walkthrough and the only hint I get is this:

return f’{self.name} available from {self.start_time}//100 am to {self.end_time}//100 pm’ How to I use something like that to change military time (2400 clock) to regular time?

I think the //100 has to be in the { } there,
like this: {self.start_time // 100} am

You might make a function with some if-statements and call that function in the repr dunder method if it gets complicated.

def format_time(military_time): hour = int(military_time // 100) minute = int(military_time % 100) is_am = military_time < 1200 or military_time >= 2400 hour = hour % 12 if hour < 1: hour = hour + 12 min = str(minute).zfill(2) # if less than 2 digits, put 0s return f'{hour}:{min} {"am" if is_am else "pm"}' time = 1501 print(f'{time} is {format_time(time)}')

Thank you. The AI help section helped me solve this f embed stuff earlier. With my python course done, I don’t know what to do next. For the moment I am watching videos on python on you tube. I am watching one that is about four hours long and I understand it better than I did before.

I still don’t know what to do from here and I am still trying to learn more about python because I don’t feel comfortable with it, albeit I feel better than I did the other two times I did it and did not succeed.

doing some simple projects helped me … even just stuff I made up to challenge myself.
And experimenting with the code in the lessons … changing some stuff or using a different function to try to figure out how it would work differently.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.