Return True if the given string contains an appearance of "xyz" where the xyz is not directly preceeded by a period(.). So "xxyz" is True but "x.xyz" is False.
One of the many correct answers is:
for i in range(len(str)):
if str[i] != '.' and str[i+1:i+4] == 'xyz':
if str[0:3] == "xyz":
Can anyone explain what the line of code means on line 3? Thanks in advance.
Source of qn: codingbat.com