當前位置:編程學習大全網 - 編程軟體 - python編程題壹道,求代碼

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')]

>>>

  • 上一篇:初中編程軟件
  • 下一篇:樹形結構圖怎麽添加下級labview
  • copyright 2024編程學習大全網