pyassistant

Sum of First and Last Elements

Given a list of integers, write a function to return the sum of the first and last elements in the list. If the list is empty, return 0.

Example:

Input:
[1, 2, 3, 4, 5]
Output:
6

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.