Computer Science, asked by unnatiwaghela1467, 7 months ago

Write a program to enter any sentence and print the number of ‘p’ or ‘P’present in the sentence

Answers

Answered by smridhi4994
0

Answer:

sentence = "Beauty lies in the eyes of beholder";

wordCount = 0;

for i in range(0, len(sentence)-1):

#Counts all the spaces present in the string

#It doesn't include the first space as it won't be considered as a word

if(sentence[i] == ' ' and sentence[i+1].isalpha() and (i > 0)):

wordCount = wordCount + 1;

Similar questions