easy +8 pts

Seconds to Hours Minutes Seconds

Convert a given number of seconds into a human-readable hours:minutes:seconds string.

Write a function `convert_seconds(seconds)` that takes a non-negative integer `seconds` and returns a string in the format `"H:MM:SS"`, where `H` is the number of hours (no leading zeros), `MM` is minutes zero-padded to two digits, and `SS` is seconds zero-padded to two digits. For example, `3661` seconds should become `"1:01:01"`. The input `seconds` is guaranteed to be a non-negative integer between 0 and 359999 (inclusive). Your function must return a string.

Constraints

Input: `0 <= seconds <= 359999`, an integer. The output must be a string. No additional imports are required.

Example

>>> convert_seconds(3661)
'1:01:01'
>>> convert_seconds(0)
'0:00:00'
>>> convert_seconds(59)
'0:00:59'
8 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use `divmod(seconds, 60)` to get minutes and remaining seconds.
Use `divmod` again on minutes to get hours and remaining minutes.
Format minutes and seconds with `f'{minutes:02d}'` to ensure two digits.
Hours should be printed without leading zeros, e.g., `1` not `01`.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.