Knowing my solution ...
Return
True
if the given string contains an appearance of "xyz
" where thexyz
is not directly preceeded by a period (.
). So "xxyz
" counts but "x.xyz
" does not.xyz_there('abcxyz') → True xyz_there('abc.xyz') → False xyz_there('xyz.abc') → True def xyz_there(str): return str.count("xyz") > str.count(".xyz")
...evolved from this code:
def xyz_there(str):
if str.count("xyz") > str.count(".xyz"):
return True
return False
I wonder if there's some rule that describes when you can flatten the IF and write is as a return value like I did?