You can use the split()
function in Python to separate the hours, minutes, and seconds into individual strings. Then, you can use the int()
function to convert the strings into integers.
Here's an example:
main.py115 chars4 lines
Output:
main.py9 chars2 lines
In this example, the split()
method is called on the time_string
variable with -
as the separator. The resulting list [ "12", "34", "56"]
is then unpacked into the variables hours
, minutes
, and seconds
. Finally, the map()
function applies the int()
function to each element in the list, converting the strings into integers.
gistlibby LogSnag