def rot(text, n):
    """Rotates 'text' by 'n' positions"""
    output = ''
    for char in text.lower():  # don't use uppercase values
        x = ord(char)
        if (x >= ord('a') and x <= ord('z')):
            x += n  # Rotate the character
            if (x > ord('z')):  # Wrap it around, if it extends past 'z'
                x = (ord('a')-1) + (x - ord('z'))
            output += chr(x)
        else:
            # It's not a letter
            output += char
    return output