pyassistant

Odd Index Element Replacement

Given a list of integers, return a new list where each element at an odd index is replaced by the sum of the element at the previous index and the element at the next index. The first and last elements remain unchanged.

Example:

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

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.