Solution:
Every time you get the error from the compiler or the interpreter you should read it carefully. The error clearly says that you did something that’s the reason the interpreter couldn’t interpret the object as an Integer.
So, where are you wrong? The range()
is expecting an integer argument, from which it will build a range of integers. You can’t put a list inside the range(), it can’t handle the list.
So, if you want to access the items in testList
, loop over the list directly, just use:
>>> testList [1,2,3,4]
>>> for i in myList:
print (i)
I hope you get the point. Thanks.