Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Get the Index of the Symbol | Section
Working with Numbers in Python: Integers, Floats, and Type Conversion - 1769704232138
Seção 1. Capítulo 21
single

single

Get the Index of the Symbol

Deslize para mostrar o menu

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'))

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.

Tarefa

Deslize para começar a programar

Hone your skills as much as possible!

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

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 21
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

some-alt