Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Hitta Ordets Index | Strängar
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Datatyper i Python

bookHitta Ordets Index

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

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.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 10
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookHitta Ordets Index

Svep för att visa menyn

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

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.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 10
single

single

some-alt