Q. Write a program to print the number of occurrences of a substring into a line using built-in string function find().
Answer =
sen = input("Enter a sentence :-") sub = input("Enter a sub-string :-") count = 0 n = 0 while n < len(sen) : n = sen.find(sub,n) if n == -1 : break else : count += 1 n += 1 print(count)
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )