Skip to content

Instantly share code, notes, and snippets.

@s0ubhik
Last active March 27, 2021 04:14
Show Gist options
  • Save s0ubhik/f4d436f0621057b7b0bcbb9fdb03926e to your computer and use it in GitHub Desktop.
Save s0ubhik/f4d436f0621057b7b0bcbb9fdb03926e to your computer and use it in GitHub Desktop.
Jumble Word
import random
def jumble(words):
if not words: return
ret = []
le = len(words)
for _ in range(le):
r = random.randint(0,le-1)
while words[r] in ret:
r = random.randint(0,le-1)
ret.append(words[r])
if ret == words: return jumble(words)
return " ".join(ret)
while True:
se = input("Enter Sentence: ")
print(jumble(se.split(" ")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment