VK

VikashKale

Programmer and Softwere Engineer at None Updated Jan. 1, 2021, 6:24 p.m. ⋅ 92 views

TCS NQT/Digital coding program 2 - Write an program to count no of words, spaces, vowel and character.


Solution Code: -

sentence = input("Enter a sentence with few strings: ")
len_of_sentence = len(sentence)

vowel_list = ['a','e','i','o','u']

space_count = sentence.count(' ')
char_count = len_of_sentence - space_count
word_count = len(sentence.split())
vowel_count = len([char_i for char_i in sentence if char_i.lower() in vowel_list])

print("words",word_count)
print("spaces",space_count)
print("characters",char_count)
print("vowels",vowel_count)

 

 

For Reference Click on  - Program_Code_video



Go back to feed

HackersFriend Updates





View more


Events


Nov. 28, 2018, 5:30 p.m.

Python from zero to hero

place Delhi

View details


Aug. 13, 2018, 5:30 p.m.

Python from zero to hero

place Bangalore ( HackersFriend office BTM Layout)

View details