If you have a list = [1,2,3,4,5]
how would you recursively calculate the length of that list without using len(list)?
myarray = [1,2,3,4,5]
def mylist(myarray):
if (myarray == []):
print ("The list is empty")
return
return 1 + ?
Don't want to use len but just add 1 each time there exists a value in list. How would I do that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…