CBSE Class 12 Computer Science
Question 90 of 136
Data File Handling — Question 29
Back to all questionsLet the file "notes.txt" include the following sample text:
Welcome to the Garden of Dreams
#where the ordinary becomes extraordinary
#the impossible becomes possible.
file_name = input("Enter the filename: ")
file = open(file_name, 'r')
lines = file.readlines()
for line in lines:
if '#' in line:
print(line)
file.close()Enter the filename: notes.txt
#where the ordinary becomes extraordinary
#the impossible becomes possible.