SHARE
TWEET

Untitled

a guest Nov 13th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. my_string = ""
  2. k = 5
  3. current_len = 0
  4. letter = my_string[0]
  5. succeded = False
  6.  
  7. for i in range(0, len(my_string)):
  8.    if my_string[i] == letter:
  9.        current_len += 1
  10.  
  11.    else:
  12.        letter = my_string[i]
  13.        current_len = 1
  14.  
  15.    if current_len == k:
  16.        print(letter * k)
  17.        succeded = True
  18.  
  19. if not succeded:
  20.    print("Didnt find a substring of length %d "% k)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top