This is my list:
nab = ['b', 'b', 'a', 'b', 'b', 'b', 'a', 'a', 'a', 'a']
I want to combine the same elements which are adjacent into another list, and if they are not the same, just return the element itself. The output that I am looking for is:
['b', 'a', 'b', 'a']
I mean:
two 'b'
---> 'b'
, one 'a'
---> 'a'
, three 'b'
---> 'b'
, four 'a'
---> 'a'
I want to know the length of the new list.