I want to split a song into multiple parts, given the song duration and number of parts.
My code achieves that, but it feels a little "stupid" and I would like to learn a more sophisticated - and shorter - way. Particularly, I feel that the marker variable is a little overkill. I would welcome any suggestions.
song_duration = 20 # these two num_of_parts = 4 # are given part_duration = song_duration / num_of_parts parts =  marker = 0 for _ in range(num_of_parts): part = [marker, marker + part_duration] marker += part_duration parts.append(part) print(parts) # parts is : [[0, 5.0], [5.0, 10.0], [10.0, 15.0], [15.0, 20.0]]