human
Check if two strings are same ignoring their cases | Function to compare two strings ignoring their cases.
length of first string.
length of second string.
if length is not same simply return false since both string can not be same if length is not equal.
loop to match one by one all characters of both string.
if current characters of both string are same , increase value of i to compare next character.
if any character of first string is some special character or numeric character and not same as corresponding character of second string then return false.
do the same for second string.
this block of code will be executed if characters of both strings are of different cases.
compare characters by ASCII value.
if characters matched , increase the value of i to compare next char.
if all characters of the first string are matched with corresponding characters of the second string , then return true.
Function to print the same or not same if strings are equal or not equal.
Driver Code"
Solution in Python:
assistant
#Here is code to check if two strings are same ignoring their cases and the other steps required.
 def equalIgnoreCase ( str1 , str2 ) :
	i = 0
	len1 = len ( str1 )
	len2 = len ( str2 )
	if ( len1 != len2 ) :
		return False
	while ( i < len1 ) :
		if ( str1 [ i ] == str2 [ i ] ) :
			i += 1
		elif ( ( ( str1 [ i ] >= ' a ' and str1 [ i ] <= ' z ' ) or ( str1 [ i ] >= ' A ' and str1 [ i ] <= ' Z ' ) ) == False ) :
			return False
		elif ( ( ( str2 [ i ] >= ' a ' and str2 [ i ] <= ' z ' ) or ( str2 [ i ] >= ' A ' and str2 [ i ] <= ' Z ' ) ) == False ) :
			return False
		else :
			if ( str1 [ i ] >= ' a ' and str1 [ i ] <= ' z ' ) :
				if ( ord ( str1 [ i ] ) - 32 != ord ( str2 [ i ] ) ) :
					return False
			elif ( str1 [ i ] >= ' A ' and str1 [ i ] <= ' Z ' ) :
				if ( ord ( str1 [ i ] ) + 32 != ord ( str2 [ i ] ) ) :
					return False
			i += 1
	return True
def equalIgnoreCaseUtil ( str1 , str2 ) :
	res = equalIgnoreCase ( str1 , str2 )
	if ( res == True ) :
		print ( " Same " )
	else :
		print ( " Not ▁ Same " )
if __name__ == ' _ _ main _ _ ' :
	str1 = " Geeks "
	str2 = " geeks "
	equalIgnoreCaseUtil ( str1 , str2 )
	str1 = " Geek "
	str2 = " geeksforgeeks "
	equalIgnoreCaseUtil ( str1 , str2 )