def rotate(password, rotate_type, *params):
    """Rotate password

    - rotate left/right X steps - means that the whole string
        should be rotated; for example, one right rotation would turn
        abcd into dabc.
    - rotate based on position of letter X - means that the whole string should
        be rotated to the right based on the index of letter X (counting
        from 0) as determined before this instruction does any rotations.
        Once the index is determined, rotate the string to the right one time,
        plus a number of times equal to that index, plus one additional time
        if the index was at least 4.
    """
    if isinstance(params[0], int):
        steps = params[0]
    else:
        index = password.index(params[1])
        steps = index + 1
        if index >= 4:
            steps += 1
    if rotate_type != 'left':
        steps = -steps
    steps = steps % len(password)
    return password[steps:] + password[:steps]