What is the best way to compare strings regardless of case?
"hello python!" "HELLO PYTHON!" "Hello PYThON!" I'd like to say that's all the same.
Please tell me the most Python-like chord
python case-insensitive compare
Assuming ASCII string The most Python method is to temporarily change the entire string to lowercase and compare it.
string1 = 'Hello'
string2 = 'hello'
if string1.lower() == string2.lower():
print "same string"
else:
print "Different String"
© 2024 OneMinuteCode. All rights reserved.