Skip to content Skip to sidebar Skip to footer

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

Post a Comment for "Python - Uppercase And Lowercase"