Код: Выделить всё
import numpy as np
def foo(n):
return(365 - n) / 365
# lim is some integer greater than 0 and less than 365
lim = 50
x = np.arange(0, lim, 1)
# foo(n) is some function
y = foo(x)
z = np.zeros(np.shape(x))
# z is the variable I'm trying to create
for i in x:
z[i] = 1 - np.prod(y[0:i+1])
Подробнее здесь: https://stackoverflow.com/questions/615 ... loop-index
Мобильная версия