belongs to collection: Python String Exercises
Write a program to find the last position of a substring “Emma” in a given string.
Given:
str1 = "Emma is a data scientist who knows Python. Emma works at google."
Expected Output:
Last occurrence of Emma starts at index 43
Hint:
Use the string function rfind()
rfind()
Solution:
str1 = "Emma is a data scientist who knows Python. Emma works at google." print("Original String is:", str1) index = str1.rfind("Emma") print("Last occurrence of Emma starts at index:", index)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use the string function
rfind()
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer