code: def reduce_accidentals(note):
      
      val = note_to_int(note[0])
      for token in note[1:]:
          if token == 'b':
              val -= 1
          elif token == '#':
              val += 1
          else:
              raise NoteFormatError("Unknown note format '%s'" % note)
      if val >= note_to_int(note[0]):
          return int_to_note(val%12)
      else:
          return int_to_note(val%12, 'b')
docs: Reduce any extra accidentals to proper notes.
  
      Example:
      >>> reduce_accidentals('C####')
      'E'