diff --git a/python/string-2/xyz_there.py b/python/string-2/xyz_there.py index 6b47103..238951f 100644 --- a/python/string-2/xyz_there.py +++ b/python/string-2/xyz_there.py @@ -1,12 +1,2 @@ -# 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. def xyz_there(str): - if str[:3] == "xyz": - return True - - for i in range(1, len(str) - 2): - if str[i-1] != "." and str[i:i+3] == "xyz": - return True - - return False + return str.count('.xyz') != str.count('xyz') #duh, it's so easy! why make it complicated?