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()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.