Re: [Tutor] Meaning of -1 in Python

2010-12-10 Thread Terry Carroll
On Fri, 10 Dec 2010, Alan Gauld wrote: "Ben Ganzfried" wrote n = s.find('not') b = s.find('bad') if n != -1 and b != -1 and b > n: s = s[:n] + 'good' + s[b+3:] return s It's clear that n!=-1 and b!=-1 means something like : "if in the string 's' we find the word "not" and in string 's

Re: [Tutor] Meaning of -1 in Python

2010-12-10 Thread Alan Gauld
"Ben Ganzfried" wrote n = s.find('not') b = s.find('bad') if n != -1 and b != -1 and b > n: s = s[:n] + 'good' + s[b+3:] return s It's clear that n!=-1 and b!=-1 means something like : "if in the string 's' we find the word "not" and in string 's' we find the word "bad." Exactly the o

[Tutor] Meaning of -1 in Python

2010-12-10 Thread Ben Ganzfried
I'm currently working through the Google Python tutorial exercises and had questions about the following function: def not_bad(s): # +++your code here+++ # LAB(begin solution) n = s.find('not') b = s.find('bad') if n != -1 and b != -1 and b > n: s = s[:n] + 'good' + s[b+3:] return