prize17-5, Exercise 2: Four-bar phrases sections = ["brass", "reeds"] phrase = 4 line = [] for bar in range(1, 13): line.append(sections[((bar - 1) // phrase) % 2]) print(line) print("brass bars:", line.count("brass"), "reeds bars:", line.count("reeds")) Output (run and checked): ['brass', 'brass', 'brass', 'brass', 'reeds', 'reeds', 'reeds', 'reeds', 'brass', 'brass', 'brass', 'brass'] brass bars: 8 reeds bars: 4 Why it works: integer division by the phrase length gives 0 for bars 1-4, 1 for bars 5-8 and 2 for bars 9-12. Taking that number modulo 2 alternates the sections. Twelve bars do not divide evenly into pairs of four-bar phrases, so brass gets one more phrase than reeds. Care: with a phrase length of 4, the 12-bar form has an odd number of phrases, so the pattern ends with the same section it began with.