PYTHON - Uppercase and Lowercase

2019-03-07 08:30发布

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 as the same thing.

1条回答
甜甜的少女心
2楼-- · 2019-03-07 09:07

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
查看更多
登录 后发表回答