两个队伍,,a不和x对战,b不和y, z,请写代码实现

 

实现如下:

#下面有两个队伍,,a不和x对战,b不和y, z,请写代码实现。
team1 = ['a', 'b', 'c']
team2 = ['x', 'y', 'z']
for team1_value in team1:  #战队1循环
    for team2_value in team2: #战队2循环
        if team1_value=='a' and team2_value=='x': #战队1等于a,战队2等于x,不进行输出,继续
            continue
        if team1_value=='b' and (team2_value=='y' or team2_value=='z'):#战队1等于b,战队2等于y或z,不进行输出,继续
            continue
        else: #非上述2种情况,进行输出
            print("%s vs  %s"%(team1_value,team2_value))
C:\Users\zhaow\AppData\Local\Programs\Python\Python37\python.exe D:/study/python/test/yc.py
a vs  y
a vs  z
b vs  x
c vs  x
c vs  y
c vs  z

 

posted @ 2019-07-18 09:13  小戳同学  阅读(272)  评论(0编辑  收藏  举报