Answers for "use index in python"

6

how to get index in python

list.index(element, start, end)
Posted by: Guest on June-30-2020
1

What is the index in python

1) how to find index of a word in a string:
  my_string = "Hello World!"

  my_string.index("l")

2) how to find the first occurance of a word in a string:
  print(verse.index('and'))
  
  
 3)how to find the last occurance of a word in a string:
  print(verse.rindex('you'))
Posted by: Guest on July-18-2021
1

how to index lists in python

# Make the list
list = ['bananas', 'apples', 'watermellon']
# Print the word apples from the list
print(list[1])
Posted by: Guest on March-29-2020

Python Answers by Framework

Browse Popular Code Answers by Language