I've got the list x which is [10,20,30,40,50]
.
So the len of x is 5.
So the following makes sense:
>>> x=[10,20,30,40,50]
>>> print(list(range(len(x))))
[0, 1, 2, 3, 4]
I've put the above into a function
and it seems to run.
What is the extra None
that I get in the output?
def foo(aList):
listLen = len(aList)
for x in list(range(listLen)):
print(x)
x=[10,20,30,40,50]
print(foo(x))
EDIT
If I apply the above to a task of reversing a list it seems fine so the None doesn't cause a problem:
def foo(aList):
newList = []
listLen = len(aList)
for x in list(range(listLen)):
newList.append(aList[listLen-(x+1)])
return newList
x=[10,20,30,40,50]
print(foo(x))