Python Check If String Contains Any Substring From The End Sql