je le code suivant:problèmes avec la gamme de python()
def steps(low, hi, n):
rn = range(n)
newrn = rn
print rn #print 1
for x in rn[:]:
print x
newrn[x] = float(x)/n
diff = hi - low
print newrn
print rn #print 2
for y in rn[:]:
print y
rn.insert(y, (newrn[y] * diff) + low)
return rn
pour une raison quelconque, ma première impression des déclarations rn [0, 1, 2], mais mon deuxième retours d'impression [0, 0,333, 666]. Pourquoi rn change? Je ne change que newrn, mais ça change aussi. Cela me fait obtenir une erreur «les index de liste doivent être entiers ne flottent pas» quand il essaye d'exécuter la ligne de rn.insert.
toute aide?