Trying to find a match in two strings - Python
- by Jacob Mammoliti
I have a user inputting two strings and then I want to check if there are any similar characters and if there is, get the position where the first similarity occurs, without using the find or index function.
Below is what I have so far but I doesn't fully work. With what I have so far, I'm able to find the similarities but Im not sure how to find the position of those similarities without using the index function.
string_a = "python"
string_b = "honbe"
same = []
a_len = len(string_a)
b_len = len(string_b)
for a in string_a:
for b in string_b:
if a == b:
same.append(b)
print (same)
Right now the output is:
['h', 'o', 'n']
So basically what I am asking is, how can I find the position of those characters without using the Python Index function?