# Return index of the last occurrence of a letter in string, # Otherwise, return -1 def get_index_of(string, letter): # print("in function") index = -1 # print("index = ", index) for i in range(len(string)-1, -1, -1): # 6, 0, +1 # print("in for, i=", i, string[i]) if string[i] == letter: # print("in if, i=", i, string[i]) index = i return index # not in there at all # Test1: inputs “python”, “z” print(get_index_of("python", "z")) # expected: -1, actual: -1 # in it, print(get_index_of("python", "h")) # expected: 3, actual: -1 # in it, at index 0 # in it, at last index # in it, at index 1 # in it, at second last index # "", "a" # "aaaaa", "" # # # Test2: inputs “python”, “p” print(get_index_of("python", "p")) # expected: 0, actual: -1 # # #