python - Requires string as left operand, not reversed Error -
so code far:
def mirror(s, v, m): rev = reversed(v) if(v in s): if(rev in s): if(m in s): return true return false str1 = "abcmcba" str2 = "abc" str3 = "m" mirror(str1, str2, str3)
it supposed return true keeps giving me error: requires string left operand, not reversed
you can streamline function following:
def mirror(s, v, m): return m in s , v in s , v[::-1] in s
note i've put fastest checks first doesn't waste time on slower operations unless they're necessary.
Comments
Post a Comment