Python Program to input any string and print words starts with consonant and vowels inthe different list
str = input ('Enter any sentence')
str+=' '
ns=''
vo_word=[]
conso_word=[]
for ch in str:
if (ch==' '):
c1=ns[0]
if (c1 in 'AEIOUaeiou'):
vo_word.append (ns)
else:
conso_word.append (ns)
ns=''
elif (ch=='.'):
pass
else:
ns+=ch
print ('Original string :', str)
print ('Vowel words:', vo_word)
print ('Consonant words: ',conso_word)
Comments
Post a Comment