/**
 * Given three lists: astronomerList, planetList, and starList,
 * append the elements of planetList to astronomerList only if the elements are present in starList.
 *
 * Example:
 * astronomerList = ['Galileo', 'Copernicus']
 * planetList = ['Mars', 'Jupiter', 'Saturn']
 * starList = ['Sun', 'Jupiter', 'Saturn']
 *
 * The expected output would be ['Galileo', 'Copernicus', 'Jupiter', 'Saturn'] as 'Mars' is not present in starList.
 *
 * @param astronomerList A list containing the astronomer names.
 * @param planetList A list containing the planet names.
 * @param starList A list containing the star names.
 * @return A new list containing the appended elements.
 */
fun appendAndIntersection(astronomerList: MutableList<String>, planetList: List<String>, starList: List<String>): List<String> {

    for (planet in planetList) {
        if (planet in starList) {
            astronomerList.add(planet)
        }
    }
    return astronomerList
}
/**
 * Given three lists: astronomerList, planetList, and starList,
 * append the elements of planetList to astronomerList only if the elements are present in starList.
 *
 * Example:
 * astronomerList = ['Galileo', 'Copernicus']
 * planetList = ['Mars', 'Jupiter', 'Saturn']
 * starList = ['Sun', 'Jupiter', 'Saturn']
 *
 * The expected output would be ['Galileo', 'Copernicus', 'Jupiter', 'Saturn'] as 'Mars' is not present in starList.
 *
 * @param astronomerList A list containing the astronomer names.
 * @param planetList A list containing the planet names.
 * @param starList A list containing the star names.
 * @return A new list containing the appended elements.
 */
fun appendAndIntersection(astronomerList: MutableList<String>, planetList: List<String>, starList: List<String>): List<String> {
/**
 * Given three lists: astronomerList, planetList, and starList,
 * append the elements of planetList to astronomerList only if the elements are present in starList.
 *
 * Example:
 * astronomerList = ['Galileo', 'Copernicus']
 * planetList = ['Mars', 'Jupiter', 'Saturn']
 * starList = ['Sun', 'Jupiter', 'Saturn']
 *
 * The expected output would be ['Galileo', 'Copernicus', 'Jupiter', 'Saturn'] as 'Mars' is not present in starList.
 *
 * @param astronomerList A list containing the astronomer names.
 * @param planetList A list containing the planet names.
 * @param starList A list containing the star names.
 * @return A new list containing the appended elements.
 */
fun appendAndIntersection(astronomerList: MutableList<String>, planetList: List<String>, starList: List<String>): List<String> {

    for (planet in planetList) {
        if (planet in starList) {
            astronomerList.add(planet)
        }
    }
    return astronomerList
}