python编程题一道,求代码

两个乒乓球队斤进行单打比赛,各出三人,三局两胜。甲队为王、陈、李三人,乙队为赵、杨、刘三人。现在通过抽签决定比赛名单。有人向队员打听比赛名单,王说他不和赵比,李说他不和找、刘比。请找出三队赛手的名单。

a = []
for i in ['w','c','li']:
for j in ['z','y','liu']:
if i == 'w' and j == 'z':
print('not match',i,j)
elif i == 'li' and j == 'z' or i == 'li' and j == 'liu':
print('not match',i,j)
elif i == 'li' and j == 'y':
print('match',i,j)
a.append((i,j))
elif i == 'w' and j == 'liu':
print('match',i,j)
a.append((i,j))
elif i == 'c' and j == 'z':
print('match',i,j)
a.append((i,j))
print(a)

输出:
>>> ================================ RESTART ================================
>>>
not match w z
match w liu
match c z
not match li z
match li y
not match li liu
[('w', 'liu'), ('c', 'z'), ('li', 'y')]
>>>
温馨提示:答案为网友推荐,仅供参考
相似回答