Light Mode
Dark Mode
Code stops working if the list is empty

Hello,

The below code works correctly if I have a list that is not empty but I can't figure out how to make it work for an empty list.

def checkio(array: list) -> int: num = [] for count, i in enumerate(array): if count % 2 == 0: num.append(i) return sum(num) * array[len(array) - 1]

Attachment
Created: Dec. 30, 2021, 9:34 p.m.
Updated: Dec. 30, 2021, 9:40 p.m.
0
3
User avatar
Zainab21