Sujet : Re: Two python issues (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 05. Nov 2024, 22:56:01
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vge49g$1nfmk$4@dont-email.me>
References : 1 2 3
User-Agent : Pan/0.160 (Toresk; )
On Tue, 5 Nov 2024 22:27:53 +0100, Piergiorgio Sartor wrote:
To write the nested expression, s[s.find(...)] it means you're 200% sure
of what happens in case of not found.
Or use s.index(...) instead of s.find(...). Then you get an exception if
the substring is not found, instead of having your program produce some
mysteriously-incorrect result.