Ch-Strings 5Q
Ch-Strings 5Q
Q4: Write a program that reads a line, then counts how many times a substring
“is” appears in the line and displays the count.
Program:
str1=input("enter a line ")
str2="is"
x=str1.split()
count=0
for i in x:
if i==str2:
count+=1
print("substring is appearing",count,"times")
Output:
Q5: Write a program that reads a string and displays the occurrence of words
starting with a vowel in the given string.
Program:
str1=input("enter line ")
x=str1.split()
count=0
for z in x:
if z[0] in "aeiou" or z[0] in "AEIOU":
count+=1
print(z)
print("no. words starting with vowels are ", count)
Output: