Write a program to accept a filename from the user and display all the lines from the file which contain Python comment character ‘#’.
Answer:
input_filename=input("Enter a file name: ")
try:
f=open(input_filename+".txt",'r')
l=f.readlines()
for line in l:
if line[0]=='#':
print(line)
except:
print("File not found")