def contains(char_string, char):
    largest_index = -1
for i, ch in enumerate(char_string):
    if ch == char:
        largest_index = i
if largest_index > -1:
    return largest_index
else:
    raise ValueError('could not find {} in {}'.format(char, char_string))
print(contains('mississippi', 's'))
print(contains('bababa', 'k'))
How to raise a ValueError?