# -*- coding: utf-8 -*-
"""
Created on 05/11/2019 at 15:14

@author: <NAME>
"""

def first_prime(L):
    """Returns the first prime in the list L.

    Parameters
    ----------
    L : list
        A list of primes.

    Returns
    -------
    firstPrime : int
        The first prime in the list L.
    """

    for i in range(len(L)):
        if L[i] <= 1:
            continue
        for j in range(2, L[i]):
            if L[i] % j == 0:
                break
        else:
            firstPrime = L[i]
            return firstPrime
    else:
        return 0

def last_prime(L):
    """Returns the last prime in the list L.

    Parameters
    ----------
    L : list
        A list of primes.

    Returns
    -------
    lastPrime : int
        The first prime in the list L.
    """

    for i in range(len(L)-1, 0, -1):
        if L[i] <= 1:
            continue
        for j in range(2, L[i]):
            if L[i] % j == 0:
                break
        else:
            lastPrime = L[i]
            return lastPrime
    else:
        return 0

def first_plus_last_prime(L):
    """Adds together the first and last primes in the list `l`. Returns
    0 if there are no primes in the list, if there is only one, the
    function returns double its value.

    Parameters
    ----------
    L : list
        The list of integers.

    Returns
    -------
    primeSum : int
        Sum of the first and last primes in `L`.
    """

    primeSum = first_prime(L) + last_prime(L)
    return primeSum

def main():

    x = [12, 12, 13, 15, 16, 16]
    print(first_plus_last_prime(x))

main()

# -*- coding: utf-8 -*-
"""
Created on 05/11/2019 at 15:14

@author: <NAME>
"""

def first_prime(L):
    """Returns the first prime in the list L.

    Parameters
    ----------
    L : list
        A list of primes.

    Returns
    -------
    firstPrime : int
        The first prime in the list L.
    """

    for i in range(len(L)):
        if L[i] <= 1:
            continue
        for j in range(2, L[i]):
            if L[i] % j == 0:
                break
        else:
            firstPrime = L[i]
            return firstPrime
    else:
        return 0

def last_prime(L):
    """Returns the last prime in the list L.

    Parameters
    ----------
    L : list
        A list of primes.

    Returns
    -------
    lastPrime : int
        The first prime in the list L.
    """

    for i in range(len(L)-1, 0, -1):
        if L[i] <= 1:
            continue
        for j in range(2, L[i]):
            if L[i] % j == 0:
                break
        else:
            lastPrime = L[i]
            return lastPrime
    else:
        return 0

def first_plus_last_prime(L):
    """Adds together the first and last primes in the list `l`. Returns
    0 if there are no primes in the list, if there is only one, the
    function returns double its value.

    Parameters
    ----------
    L : list
        The list of integers.

    Returns
    -------
    primeSum : int
        Sum of the first and last primes in `L`.
    """

    primeSum = first_prime(L) + last_prime(L)
    return primeSum

def main():

    x = [12, 12, 13, 15, 16, 16]
    print(first_plus_last_prime(x))

main()

# -*- coding: utf-8 -*- Created on 05/11/2019 at 15:14  @author: <NAME> Returns the first prime in the list L.      Parameters     ----------     L : list         A list of primes.      Returns     -------     firstPrime : int         The first prime in the list L. Returns the last prime in the list L.      Parameters     ----------     L : list         A list of primes.      Returns     -------     lastPrime : int         The first prime in the list L. Adds together the first and last primes in the list `l`. Returns     0 if there are no primes in the list, if there is only one, the     function returns double its value.      Parameters     ----------     L : list         The list of integers.      Returns     -------     primeSum : int         Sum of the first and last primes in `L`.