deldouble

deldouble
 avatar
unknown
python
a year ago
558 B
11
Indexable
import random, string

LOW = string.ascii_lowercase
shuffled_combined = "Eoooor"

s = list(shuffled_combined.lower())
i = 0
while i < len(s):
    if s[i] not in LOW:
        i += 1
        continue
    j = i + 1
    while j < len(s) and s[j] == s[i]:
        j += 1
    for k in range(i+1, j):
        pick = random.choice([c for c in LOW if c != s[k-1]])
        s[k] = pick
    i = j

result = ''.join(s)
if result:
    result = result[0].upper() + result[1:]
print("shuffled_combined:", shuffled_combined)
print("result:", result)
Editor is loading...
Leave a Comment