-4
a=input("enter string: ")
count=0
if 'emma' in a:
    count=count+1
else:
    print("not found")
print("no of emmas in string:"+count)
bigbounty
  • 16,526
  • 5
  • 37
  • 65
  • 2
    Why should it count more than 1? You don't have a loop, so it only executes once. – Barmar Aug 11 '20 at 07:19
  • 1
    what is the problem ? if you run it only once then you can't get bigger value. You didn't show what data you use and what result you expected. – furas Aug 11 '20 at 07:19

2 Answers2

0

Use .count on the string instead

a=input("enter string: ")
print("no of emmas in string: {} ".format(a.count('emma')))

Output:

enter string: emma emma
no of emmas in string: 2
bigbounty
  • 16,526
  • 5
  • 37
  • 65
0
a=input("enter string: ")
print(a.count('emma'))