Search code examples
pythonpython-2.7python-idle

PYTHON - Uppercase and Lowercase


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.


Solution

  • 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