Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Word Scrabbler - Completely Random - Python Code Bank


Word Scrabbler - Completely Random
This simple python script I wrote takes a single word provided on the cmd line and outputs a scrabbled version - It Is As Simple As That
                import random
import sys
import string

numberArgs = len(sys.argv)

if numberArgs == 1:
    print "Usage: " + sys.argv[0] + " [word to scramble]"
elif numberArgs == 2:
    toScramble = sys.argv[1]
    letterList = list(toScramble)
    random.shuffle(letterList)
    stringScrambled = ''.join(letterList)

    while (stringScrambled == toScramble):
        letterList = list(toScramble)
        random.shuffle(letterList)
        stringScrambled = ''.join(letterList)

    print "Your Word '" + toScramble + "' Has Been Randomly Scrambled To: " + stringScrambled
else:
    print "The Scrambler Can Only Scramble One Word At A Time!"
            
Comments
Sorry but there are no comments to display