str_x = "Emma is good developer. Emma is a writer"
# use count method of a str class
cnt = str_x.count("Emma")
print(cnt)
Solution 2:Without string method
def count_emma(statement):
print("Given String: ", statement)
count = 0
for i in range(len(statement) - 1):
count += statement[i: i + 4] == 'Emma'
return count
count = count_emma("Emma is good developer. Emma is a writer")
print("Emma appeared ", count, "times")
Hint:
Use string method
count().Solution 1: Use the
count()methodSolution 2:Without string method
need an explanation for this answer? contact us directly to get an explanation for this answer