### Invert Pitch Set

Fundamentals

Write a function that takes a list of 12 UNIQUE numbers, ranging from 0 to 11. Find the interval difference of each step, and reverse the interval in the new set.

If the number is less than 0, it should wrap around. For example, if -1, then 11. If -2, then 10.

Also if the number is greater than 11, the number should be subtracted by 12.

The first number in the new set should be the same as the original set.

For example:

[7, 6, 4, 3, 1, 11, 10, 0, 9, 8, 2, 5] should return [7, 8, 10, 11, 1, 3, 4, 2, 5, 6, 0, 9]

(I'm having a hard time putting the description into words that make this seem completely independent to music. Knowing and understand music theory would make this a lot easier to understand)

``````def invert(testset):

base12 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

invset = [(testset[0])]
for s in range(len(testset)-1):
interval = testset[s] - testset[s+1]
if s == 0:
inv_val = testset[s] + interval
if inv_val > 11:
inv_val = inv_val - 12
else:
inv_val += interval
if inv_val > 11:
inv_val = inv_val - 12
if inv_val < 0:
inv_abs = base12[inv_val]
else:
inv_abs = inv_val
invset.append(inv_abs)
return(invset)``````