首页 > 代码库 > 三种方法打印列表(数组)

三种方法打印列表(数组)

#方法一
member = [‘小甲鱼‘, 88, ‘黑夜‘, 90, ‘迷途‘, 85, ‘怡静‘, 90, ‘秋舞斜阳‘, 88]
i=0
lenth=len(member)
while i<lenth:
    print(member[i],member[i+1])
    i+=2
#方法二
member = [‘小甲鱼‘, 88, ‘黑夜‘, 90, ‘迷途‘, 85, ‘怡静‘, 90, ‘秋舞斜阳‘, 88]
i=0
for string in member:
    print(member[i],member[i+1])
    i+=2
#方法三
member = [‘小甲鱼‘, 88, ‘黑夜‘, 90, ‘迷途‘, 85, ‘怡静‘, 90, ‘秋舞斜阳‘, 88]
for each in range(len(member)):
    if each%2==0:
        print(member[each],member[each+1])

三种方法打印列表(数组)