lsit_a = [2, 4, 3, 6, 3, 8, 5]
list comprehension is very useful.
list_b = [a**2 for a in list_a]
I want to know how to write a self-reference in the python list comprehension.
for example -
list_c = [a**2 if i == 0 else a*2 + (itself[i-1]) for i, a in enumurate(list_a)]
how to write the part of itself[i-1]?
ADD
Sorry, my explain is bad...
I want to get the list by a high-speed way.
input list
list_a = [0,0,1,0,0,0,1,0,0,1,0]
output list
list_c = [0, 0, 1, 0.9, 0.8, 0.7, 1, 0.9, 0.8, 1, 0.9]
like a saw tooth list.