python编程,给定一个列表,写一段程序判断这个列表的长度
列表不是有自带的len()方法么? 判断什么长度
s = [1,2,3,4,5]
#1、自带方法
print(len(s))
#2、自己写判断长度
count = 0
for i in s:
count+=1
print(count)
s = [1,2,3,4,5]
#1、列表自带方法
print(len(s))
#2、自己判断
count = 0
for i in s:
count+=1
print(count)