import string


def rotN(text, n, alphabet=string.ascii_lowercase):
    """Rotate text by N positions, based on given alphabet.
    
    If a character is not in the alphabet it is kept as is.
    """
    rotated = ''
    for c in text:
        try:
            rotated += alphabet[(alphabet.index(c) + n) % len(alphabet)]
        except ValueError:
            rotated += c
    return rotated