Question #230789

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’.

Expert's answer

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()
LATEST TUTORIALS
APPROVED BY CLIENTS