Python Write a program that shall ask the user to enter any

Python.

Write a program that shall ask the user to enter any text and then display three strings, the first of which consists of all the vowels from the text, the second, of all consonants, and the third, of all other characters. Each string shall be displayed on a separate line. The order of characters in the displayed strings shall be the same as in the original text. Example: Enter text: Hello, world! eoo Hllwrld, !

Solution


def countvowels(string):
  
vowel=\"\"
for char in string:
if char in \"aeiouAEIOU\":
vowel=vowel+char
return vowel
def countconsonant(string):
  
consonant=\"\"
for char in string:
if char in \"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\":
consonant=consonant+char
return consonant
def countother(string):
  
other=\"\"
for char in string:
if char not in \"aeiouAEIOUbcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\":
other=other+char
return other
  
person = raw_input(\'Enter your name: \')
print person;
print countvowels(person)
print countconsonant(person)
print countother(person)

Python. Write a program that shall ask the user to enter any text and then display three strings, the first of which consists of all the vowels from the text, t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site