Write a Python function called encode( string_to_be_encoded, is_case_sensitive=True ) that takes a string, which will be encoded according to the following scheme and a parameter named is_case_sensitive, which controls whether uppercase and lowercase versions of the same letter should matter or not. Your function will return a list that will contain sublists, which will express the code.

When is_case_sensitive=False, then the character values returned should all be lowercase.

Encoding scheme
Instead of keeping each consecutively repeating character, you will create a sublist in which the first element will be the current character under consideration and second element will be the total number of consecutive repeats of that character.

Each sublist should incrementally be addeded to the end of running answer list that your function will eventually return.

Examples
Consider the following three examples:

In [1]: encode( 'wwwwaaadexxxxxx' )
Out[1]: [['w', 4], ['a', 3], ['d', 1], ['e', 1], ['x', 6]]

In [2]: encode( 'wwwwaaadexxxxxxww' )
Out[2]: [['w', 4], ['a', 3], ['d', 1], ['e', 1], ['x', 6], ['w', 2]]

In [3]: encode( 'wadexwbde' )
Out[3]: [['w', 1], ['a', 1], ['d', 1], ['e', 1], ['x', 1], ['w', 1], ['b', 1], ['d', 1], ['e', 1]]

In [4]: In [5]: encode( 'aaAAAaaaAAaaaaA', is_case_sensitive=True )
Out[4]: [['a', 2], ['A', 3], ['a', 3], ['A', 2], ['a', 4], ['A', 1]]

In [5]: In [5]: encode( 'aaAAAaaaAAaaaaA', is_case_sensitive=False )
Out[5]: [['a', 15]]
Consider the first example where the input string is 'wwwwaaadexxxxxx'. Here the w character repeats four times. Hence the sublist ['w', 4] in the list returned by the function. This is followed by three consecutive occurrences of letter a, hence the sublist ['a', 3]. Third, we have only a single occurrence of letters d and e. Hence, the sublists ['d', 1] and ['e', 1]. Finally, letter x occurs six times. Hence the final sublist ['x', 6] in the returned list.

Additional Specifications
You are not allowed to use any modules. So no import statements should appear in your code. If you fail to abide by this requirement, you will automatically receive a zero for this exercise, since your tests will not work!
You will store your code in an output file that will be named "encode.py". To do this, you will use file magic, which has already been done for you. So do not remove the file magic command at the top of the following code cell.
Suggestions
You may wish to develop your program using GVIM and the terminal in which your run Python or IPython. Then you can copy and paste the code you developed into your notebook at the appropriate time. I frequently find this to be a good method of working. For example, if your code gets into an infinite loop, your browser may lock up. However, in the terminal, you can stop an infinitely looping program by pressing Ctrl+C.
Please do not switch the order of the letters and counts in the sublists.
Please do not change the case of each letter in the returned list.
I M P O R T A N T W A R N I N GIf you decide to work with the file magic command, then on each modification of your code, please consider reloading this notebook by pressing F5 on your keyboard! Otherwise, your modifications may not take effect in the current session! If you fail to reload, you may get confused as to why your most recent changes you just made are not taking effect.

A better option is to include the magic commands

%reload_ext autoreload
%autoreload 2
before user-defined modules are loaded in a cell, as demonstrated in the test cells below.

Hint: Nested looping
Do not rush. Instead, design an algorithm on paper. Check your algorithm, and when you are sure your algorithm works, only then start coding. If you fail to work systematically, you are highly likely to run out of time! On the other hand, if you follow a systematic approach, you will conserve time, and your chance of success will be much higher than otherwise.
You need to write about 12 lines of code for this problem! However, you must plan your work as I suggested to your right above!

SMH