Python requires its code to be indented and spaced properly. Never mix tabs and spaces. If you're using tabs stick to tabs and if you're using space stick to space.
Also in your code, change this part:
if str_p == str_q:
result = True
result = False
return str_p == str_q
Hope it helps!!
If you need to know more about Python, It's recommended to join Python course today.