PYTHON - Uppercase and Lowercase

2019-03-07 08:05发布

问题:

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:

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