my_str='Welcome to Plus2net'
output=my_str.lower()
print(output) # welcome to plus2net
my_str='WELCOME TO PLUS2NET'
output=my_str.lower()
print(output) # welcome to plus2net
my_str='welcome to plus2net'
output=my_str.lower()
print(output) # welcome to plus2net
When applying lower() to strings with numbers or special characters, only alphabetic characters are affected:
my_str = "Hello123!@#"
print(my_str.lower()) # Output: "hello123!@#"
When comparing user inputs, converting strings to lowercase ensures case-insensitive comparisons:
input_str = "Yes"
if input_str.lower() == 'yes':
print("Input accepted.")
output
Input accepted.
All String methods upper() islower() isupper()