Reputation: 43
Here's the code that i'm using:
pie = []
start = 102
stop = 1
step = 1
for i in range(stop,start):
result = (i - step) / 100
pie.append(result)
print(pie)
for i in pie:
result = pie[i] * pie[i-1]
pie.append(result)
print(pie)
and here's the error that i'm getting:
TypeError: list indices must be integers or slices, not float
Upvotes: 1
Views: 1058
Reputation: 2169
You have added float numbers in pie
list:
result = (i - step) / 100
pie.append(result) # [0.0, 0.01, 0.02, ...]
Then you used those numbers here as index:
for i in pie:
result = pie[1] * pie[i - 1]
pie.append(result)
Error is also saying same thing: list indices must be integers or slices, not float
Upvotes: 1