这是我在学校课堂上上的一堂课的代码,我对列表的打印方式感到困惑,因为它一直以“无”结尾......
def printlist(myList, pointer):
print("The List is: ", myList)
print("Pointer length: ", pointer)
print("The List length is: ", len(myList))
print("The List printed properly:")
print(printlistproperly(myList))
def printlistproperly(myList):
thelength = len(myList)
for i in range(thelength):
print(i, " ", myList[i])
def popin(myList,pointer):
myList.append(input("Enter a value: "))
pointer = len(myList)-1
return myList, pointer
def main():
myList = ["Ford","Toyota","Mustang"]
pointer = len(myList)-1
myList,pointer = popin(myList,pointer)
printlist(myList, pointer)
结果是:
>>> main()
Enter a value: Dodge
The List is: ['Ford', 'Toyota', 'Mustang', 'Dodge']
Pointer length: 3
The List length is: 4
The List printed properly:
0 Ford
1 Toyota
2 Mustang
3 Dodge
None
我真正的问题是......最后的None是什么?它从何而来?我该如何解决?