Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
3. Time object: internal elements


Good job! Internally, time objects consist of four elements: hour, minute, second, and microsecond. To get a specific element, you can use the following syntax:

fra_mad_scheduled = datetime.time(9, 30, 0)

print('Hour:', fra_mad_scheduled.hour)
print('Minute:', fra_mad_scheduled.minute)
print('Second:', fra_mad_scheduled.second)
print('Microsecond:', fra_mad_scheduled.microsecond)

As you can see, we used the dot operator (.) to get the specific hour, minute, second, or microsecond element.


Modify the template from the previous exercise so that it formats time in the following way:

Typical work start time is 8.45

Note that we expect the hour and minutes to be separated with a dot (.), and not a colon (:), which is the default time format.

Note: from now on, we will be importing the datetime module for you. 🙂

Stuck? Here's a hint!

You'll have to extract the hour and minute elements separately and add a dot between them.