Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions python/string-2/xyz_there.py
Original file line number Diff line number Diff line change
@@ -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?