Python中的作业IF语句

时间:2019-06-18 12:28:05

标签: python

我是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

2 个答案:

答案 0 :(得分:1)

您应该使用or语句:

if airline == 'klm' or airline == 'ana':

in关键字:

if airline in ('klm', 'ana'):

答案 1 :(得分:1)

if airlines in ('klm', 'ana'):