Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Examples for string find() in Python

Soham1087

Newbie
Joined
May 31, 2022
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
India
Activity points
19
I (beginner) am trying to find some examples but no luck.

Does anyone know of some examples on the net? I would like to know what it returns when it can't find, and how to specify from start to end, which I guess is going to be 0, -1.

From Scaler I got the following resolution, but still unsure about it. Need your valuable insights on it.

Python:
>>> x = "Hello World"
>>> x.find('World')
6
>>> x.find('Aloha');
-1
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
21,980
Helped
4,591
Reputation
9,196
Reaction score
4,808
Trophy points
1,393
Activity points
145,106
Hi,

"-1" means "not found"
">=0" means the position in the string, beginning with 0

H --> pos 0
e --> pos 1
l --> pos 2
l --> pos 3
o --> pos 4
[ ] --> pos 5
W --> pos 6
o --> pos 7
...


Klaus
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top