Light Mode
Dark Mode
I don't understand how to fix next problem.

Hi to all! That's my code:

a = [1,2,3,4]

number = 2

def index_power(number, a):

l = len(a)

d = 0

for i in range(0, l):

if i == number:

d = a[i] ** number

return d

elif number > l:

return -1

print(index_power(number, a))

But I got an error message when I run code in Checkio editor:

TypeError: object of type 'int' has no len()

index_power, 4

<module>, 16

But when I run it in Pycharm, function executed without errors. Does anyone know, why this is appear in Checkio?

Created: May 4, 2016, 2:57 p.m.
Updated: May 5, 2016, 3:29 p.m.
1
4
User avatar
Leonid_Yampolsky