Ad
Arithmetic
Mathematics
Algorithms
Logic
Numbers

Input:
A list of length 1 to 10

Output:
The sum of the last two items of the list

Examples:

  • [1,2] -> 3
  • [-1,2] -> 1
  • [2,2,-4] -> -2
  • [4] -> 4
def sum_last_two_items(ls):
    return ls[-1]+ls[-2] if len(ls)>1 else ls[0]