Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Find the Word Index | Strings
Data Types in Python
course content

Course Content

Data Types in Python

Data Types in Python

1. Getting Familiar With Numbers in Python
2. True or False?
3. Strings
4. Bring All the Topics Together

bookFind the Word 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').

Note

The index() function returns the first occurrence of the word in the string, and the valuable point is that it throws an exception if the word is not found.

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 10
toggle bottom row

bookFind the Word 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').

Note

The index() function returns the first occurrence of the word in the string, and the valuable point is that it throws an exception if the word is not found.

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 10
toggle bottom row

bookFind the Word 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').

Note

The index() function returns the first occurrence of the word in the string, and the valuable point is that it throws an exception if the word is not found.

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

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

Note

The index() function returns the first occurrence of the word in the string, and the valuable point is that it throws an exception if the word is not found.

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 10
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt