📜  python代码示例中的索引

📅  最后修改于: 2022-03-11 14:46:01.103000             🧑  作者: Mango

代码示例5
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'))