Last active
March 27, 2021 04:14
-
-
Save s0ubhik/f4d436f0621057b7b0bcbb9fdb03926e to your computer and use it in GitHub Desktop.
Jumble Word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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