关于python第十讲课后练习题
方法一:count = 0
length = len(member)
while count < length:
print(member, member)
count += 2
方法二:
for each in range(len(member)):
if each%2 == 0:
print(member, member)这两种方法可以实现小甲鱼 88
黑夜 90
迷途 85
怡静 90
秋舞斜阳 88这样,我有点看不懂这两种方法,求大神解释一下,谢谢 count = 0
length = len(member)#得长度
while count < length: #count取值依次为0,2,4,6,8
print(member, member) #输出索引依次为:0,1,2,3,4,5,6,7,8,9,刚好全部打印完
count += 2
for each in range(len(member)):#count取值以此为0,1,2,3,4,5,6,7,8,9
if each%2 == 0: #符合要(偶数)求得count为:0,2,4,6,8
print(member, member)#输出索引依次为:0,1,2,3,4,5,6,7,8,9,刚好全部打印完
解释在注释里,应该比较清楚了
满意的话还请设置个最佳答案
页:
[1]