result
? lst = [0, 7, 1, 0, 4, 2, 5, 4, 0, 9]
for n, item in enumerate(lst):
if n%2 == 0 and item == 0:
lst[n+1] = 0
elif n%2 > 0 and item == 0:
lst[n-1] = 0
print(lst)
isinstance
, а не через type
. Ну и, как указал Александр Нестеров , тут всяко будет str
.