MCPcopy Index your code
hub / github.com/kyclark/tiny_python_projects / scramble

Function scramble

16_scrambler/solution.py:48–56  ·  view source on GitHub ↗

For words over 3 characters, shuffle the letters in the middle

(word)

Source from the content-addressed store, hash-verified

46
47# --------------------------------------------------
48def scramble(word):
49 """For words over 3 characters, shuffle the letters in the middle"""
50
51 if len(word) > 3 and re.match(r'\w+', word):
52 middle = list(word[1:-1])
53 random.shuffle(middle)
54 word = word[0] + ''.join(middle) + word[-1]
55
56 return word
57
58
59# --------------------------------------------------

Callers 1

test_scrambleFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_scrambleFunction · 0.68