不理解

a = ['p', 'y', 't', 'h']
t = 0
while t<2:
    t += 1
    for i in a:
    # 循环条件为真时终止执行continue后的语句,
    # 循环条件为假时执行continue后的语句
        if i == 'y':
            a.remove('y')
            continue
        print(i)


list1 = [1, 2, 3, 4]
t = 0
while t<2:
    t += 1
    for i in list1:
        if i == 2:
            list1.remove(2)
            continue
        print(i)
p
h
p
t
h
1
4
1
3
4

猜你喜欢

转载自www.cnblogs.com/joeshang/p/12541782.html