Answer to Question #200472 in Python for Angelica

Question #200472

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.


1
Expert's answer
2021-05-30T07:25:04-0400
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)
        
        

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS