Write a function in a PYTHON to read the content of a text file “DELHI.TXT” and display all
those lines on screen, which are either starting with ‘D’ or starting with ‘M’.
1
Expert's answer
2021-08-30T01:35:28-0400
def starts_with_dm():
with open('DELHI.TXT') as file:
for line in file:
if line.startswith('D') or line.startswith('M'):
print(line)
starts_with_dm()
Comments
Leave a comment