emp = []
def run(first, second):
front_index = 0
back_index = 0
if len(first) > len(second):
front = second
back = first
num = first_bigger_than_second(front, back)
return num
elif len(first) < len(second):
front = first
back = second
break
else:
front = second
back = first
break
def first_bigger_than_second(first, back):
first_index = 0
back_index = 0
print(len(first))
print(len(back))
while first_index < len(first) and back_index < len(back):
if first[first_index] == back[back_index] and back_index == len(back):
print("first", first)
print("first_index", first_index)
print("first[first_index]", first[first_index])
print("back", back)
print("back_index", back_index)
print("back[back_index]", back[back_index])
emp.append(back[back_index])
first_index += 1
back_index = 0
print(1)
elif first[first_index] == back[back_index]:
print("first", first)
print("first_index", first_index)
print("first[first_index]", first[first_index])
print("back", back)
print("back_index", back_index)
print("back[back_index]", back[back_index])
emp.append(back[back_index])
back_index += 1
print(2)
elif back_index == len(back) - 1:
print("first", first)
print("first_index", first_index)
print("first[first_index]", first[first_index])
print("back", back)
print("back_index", back_index)
print("back[back_index]", back[back_index])
first_index += 1
back_index = 0
print(3)
else:
print("first", first)
print("first_index", first_index)
print("first[first_index]", first[first_index])
print("back", back)
print("back_index", back_index)
print("back[back_index]", back[back_index])
back_index += 1
print(4)
num1 = 0plm1qaz
num2 = 1qaz0pl
run(num1, num2)
print(emp)
"""
All the print functions are used to trace with if loop is been executed
The problem is when I print the emp, the output is ["1", "q", "a", "z"] expected output is: ["1", "q", "a", "z", "0", "p", "l"].
The code compares two word user inputs and returns the same word. Example: When you input "2aba" and "2ac" , it will give a result as ["2", "a", "a"] since the code is work like the "2" from the "2aba" compare with "2ac" and the "a" from the "2aba" is compared again with "2ac" and "b" from the "2aba" is compared with "2ac" and "a" from the "2aba" compare with "2ac"