def print_string_with_markers(strn, pValue): out = strn[:pValue] + '«' + strn[pValue] + '»' + strn[pValue+1:] return out def extra_character_index(str1, str2): # Initialize the result variable to store the result result = 0 # Store the length of str1 in str1_length variable str1_length = len(str1) # Store length of str2 in str2_length variable str2_length = len(str2) # Traverse the string 1 till the end and perform xor with the result print("\n\tTraversing the first string") for i in range(str1_length): print("\t\t", print_string_with_markers(str1, i), sep="") print("\t\tCurrent character:", str1[i]) print("\t\tresult:", result) print("\t\tPerforming XOR operation") print("\t\t\tresult XOR ASCII(", str1[i], ") = ", result, " XOR ", (ord)(str1[i]), sep="") # Perform the xor operation with the result result = result ^ (ord)(str1[i]) print("\t\tresult:", result, "\n") def main(): # given string string1_list = ["wxyz", "cbda", "jlkmn", "courae", "hello"] string2_list = ["zwxgy", "abc", "klmn", "couearg", "helo"] for i in range(len(string1_list)): print(i+1, ".\tString 1 = ", string1_list[i], "\n\t", "String 2 = ", string2_list[i], sep="") extra_character_index(string1_list[i], string2_list[i]) print("-"*100) if __name__ == '__main__': main()