write a python program to accept a string. do this continuosly until the user enters the enter key only. then save all those strings into a file named user_strings . text . open and read the saved file to print the number of occurence of the vowels and non-vowels.
st=""
while True:
s=input("Enter a string: ")
if s.upper()=="ENTER":
break;
st+=s+" "
f = open("user_strings.txt", "a")
f.write(st)
f.close()
f = open("user_strings.txt", "r")
s3=f.read()
vcount = 0
for i in s3:
if( i=='A' or i=='a' or i=='E' or i=='e' or i=='I'
or i=='i' or i=='O' or i=='o'
or i=='U' or i=='u'):
vcount +=1
print('The Number of Vowels in text file :', vcount)
ncount=0
for i in s3:
if i!=" ":
ncount+=1
nv_count=ncount-vcount
print('The Number of Non Vowels in text file :', nv_count)
Comments
Leave a comment