Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Trovare l'Indice della Parola | Stringhe
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Tipi di Dati in Python

bookTrovare l'Indice della Parola

Hi there, it should be mentioned that there is another function that does the same action as find(), which is called index().

Like the very similar function find(), it finds the first appearance of the word. Look at the example to clarify its usage:

1234567
string = "I can manage everything" manage = string.index('manage') everything = string.index('everything') print("The index of the word manage is", manage) print("The index of the word everything is", everything)
copy

As you may have recognized, the index() function has the following syntax:

string.index('word')
Compito

Swipe to start coding

Here's one more simple task to increase your knowledge base.

  1. Find the index of the word burning.
  2. Find the index of the word desire.
  3. Find the index of the word studying.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 10
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Suggested prompts:

What is the difference between `find()` and `index()`?

What kind of exception does `index()` throw if the word is not found?

Can you show an example where `index()` throws an exception?

close

bookTrovare l'Indice della Parola

Scorri per mostrare il menu

Hi there, it should be mentioned that there is another function that does the same action as find(), which is called index().

Like the very similar function find(), it finds the first appearance of the word. Look at the example to clarify its usage:

1234567
string = "I can manage everything" manage = string.index('manage') everything = string.index('everything') print("The index of the word manage is", manage) print("The index of the word everything is", everything)
copy

As you may have recognized, the index() function has the following syntax:

string.index('word')
Compito

Swipe to start coding

Here's one more simple task to increase your knowledge base.

  1. Find the index of the word burning.
  2. Find the index of the word desire.
  3. Find the index of the word studying.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 10
single

single

some-alt