Write a program to accept string/sentences from the user till the user enters END to. Save the data

Опубликовано: 22 Октябрь 2024
на канале: Portal Express
413
11

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.

Website Link :-
https://www.pathwalla.com/2021/05/wri...

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