我正在这个网站上练习我的 python 编码。这就是问题
Return True if the given string contains an appearance of "xyz" where the xyz 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):
counter = str.count(".xyz")
if ( counter > 0 ):
return False
else:
return True