Python count group letters in a string

Say we have a string like “abaabbbccccaaac”. We want to count same group of letters in a string and display like “a1b1a2b3c4a3c1” The code is given below: a = "abaabbbccccaaac" o = "" while len(a) > 0: count = 0 i = 0 ch = a[0] while i < len(a) and a[i] == ch: count += 1 i += 1 a = a[count:]...

Python using any, all

any and all can be think of as a series of logical or and and operators. any any will return True when at-least one of the elements is True all all will return True only when all the elements are True Internal structure of any(iterable) def any(iterable): for element in iterable: if element: return...


Imran Pollob

Learn => Practice => Implement => Repeat

Get in touch