Print a random anagram of a given string I am given a task to create a function that prints a random anagram of a given string:

def anagram(value):
    '''Prints random anagram of given value'''
    import random
    newWord = ''
    for i in range(len(value)):
        pos = random.randint(0, len(value)-1)
        newWord += value[pos]
        value = value[:pos] + value[pos+1:]
    print newWord


anagram('12345')
anagram('should')


What all edge cases should this program cover?
When building a string you should build a list, and then use ''.join(). This is as strings are immutable, and so generating newWord takes \$O(n^2)\$ time.
You are mannually poping pos from value. If you change value to a list, you can just use list.pop.
You should import random at the top of your code. Never in a function.
Common Python style is to use snake_case for variables.
Common Python style is to use _ as a throw away variable.
You can use random.randrange, rather than randint
It's best if you return rather than print your anagram.


And so you could use:

def anagram(value):
    new_word = []
    value = list(value)
    for _ in range(len(value)):
        pos = random.randrange(len(value))
        new_word.append(value.pop(pos))
    return ''.join(new_word)


This however runs in \$O(n^2)\$ time. If you use a Fisher–Yates shuffle, you can do this in \$O(n)\$ time.

def anagram(value):
    value = list(value)
    for i in range(len(value)):
        pos = random.randrange(i, len(value))
        value[i], value[pos] = value[pos], value[i]
    return ''.join(value)




You can also use random.shuffle, which likely also uses the above algorithm. However you won't have to maintain it. Allowing:

def anagram(value):
    value = list(value)
    random.shuffle(value)
    return ''.join(value)