Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer De Index Van Het Symbool Ophalen | Strings
Gegevenstypen in Python

bookDe Index Van Het Symbool Ophalen

To find the index of a specific symbol or substring in a string, Python provides the built-in .find() method. This method returns the index of the first occurrence of the substring. If the substring is not found, it returns -1.

string.find(substring)

Here, string is the original text, and substring is the character or sequence you want to locate.

12
string = "Channel efforts to success!" print(string.find('n'))
copy

In the string "Channel efforts to success!", the first 'n' appears at index 3. So, the find() method returns 3.

If the character were not found, for example, string.find('z'), the result would be -1.

Taak

Swipe to start coding

Hone your skills as much as possible!

So here you should find the index of the letters p, y, and r.

Oplossing

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 9
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

close

bookDe Index Van Het Symbool Ophalen

Veeg om het menu te tonen

To find the index of a specific symbol or substring in a string, Python provides the built-in .find() method. This method returns the index of the first occurrence of the substring. If the substring is not found, it returns -1.

string.find(substring)

Here, string is the original text, and substring is the character or sequence you want to locate.

12
string = "Channel efforts to success!" print(string.find('n'))
copy

In the string "Channel efforts to success!", the first 'n' appears at index 3. So, the find() method returns 3.

If the character were not found, for example, string.find('z'), the result would be -1.

Taak

Swipe to start coding

Hone your skills as much as possible!

So here you should find the index of the letters p, y, and r.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 9
single

single

some-alt