Q. Write a program to accept string/sentences from the user till the user enters "END" to. Save the data in a text file and then display only those sentences which begin with an uppercase alphabet.


You can understand by Watching video :-



Answer :-

f = open("Pathwalla.txt","w")
while True :
	sen = input("Enter something ( for quit enter END ) :-")
	if sen == "END" :
		break
	else :
		f.write(sen + "\n")
f.close()
print()
print("The Lines started with Capital letters are :-")
f = open("Pathwalla.txt","r")
print()
data = f.readlines()
for i in data :
	if i[0].isupper() :
		print(i)
f.close()

Output :-

Enter something ( for quit enter END ) :-This is Pathwalla website
Enter something ( for quit enter END ) :-here you can get all answer
Enter something ( for quit enter END ) :-Related to CS and IP
Enter something ( for quit enter END ) :-ok3
Enter something ( for quit enter END ) :-Thank you
Enter something ( for quit enter END ) :-END

The Lines started with Capital letters are :-

This is Pathwalla website
Related to CS and IP
Thank you

>>> 

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. will this program saving the input in file and if yes what would be the location of the same

    ReplyDelete
    Replies
    1. Yes, it will save data in Pathwalla.txt in same location of your python .py file.

      Delete
  2. But in sen if we enter 'this is going to end' in one line then it will not break the loop right

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post