Printing frequency of each character just after its consecutive occurrences | Python 3 program to print run length encoding of a string ; Counting occurrences of s [ i ] ; Driver Code
def printRLE ( s ) : NEW_LINE INDENT i = 0 NEW_LINE while ( i < len ( s ) - 1 ) : NEW_LINE INDENT count = 1 NEW_LINE while s [ i ] == s [ i + 1 ] : NEW_LINE INDENT i += 1 NEW_LINE count += 1 NEW_LINE if i + 1 == len ( s ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( str ( s [ i ] ) + str ( count ) , end = " ▁ " ) NEW_LINE i += 1 NEW_LINE DEDENT print ( ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT printRLE ( " GeeeEEKKKss " ) NEW_LINE printRLE ( " cccc0ddEEE " ) NEW_LINE DEDENT