我是Python的新手,我想从KLM,United和ANA制作。我怎么做?谢谢
airlines = ['klm', 'united', 'ana']
for airline in airlines:
if(airline == 'klm' and airline == 'ana'):
print(airline.upper())
else:
print(airline.title())
我希望它显示: 荷航 联合的, ANA
答案 0 :(得分:1)
您应该使用or语句:
if airline == 'klm' or airline == 'ana':
或in
关键字:
if airline in ('klm', 'ana'):
答案 1 :(得分:1)
或if airlines in ('klm', 'ana'):