PYTHON - Uppercase and Lowercase

前端 未结 1 1349
陌清茗
陌清茗 2021-01-29 16:23

In my code it is;

If \'Laia\' in name:

But how do I make it so even if they input; LaIa or laiA. No matter what case(upper or lower) it reads a

1条回答
  •  北海茫月
    2021-01-29 17:09

    I would suggest you convert all input to lowercase using the .lower() function, and compare the input with a lowercase string: 'laia' like so

    name = raw_input('What is the name? ').lower()
    if name == 'laia':
        # do stuff
    

    0 讨论(0)
提交回复
热议问题