Write a Python program to cut out and display just the Preamble (We the People…).
we are trying to pull that line from a text file
filename = input("Enter file name: ") # ask for file name try: with open(filename, 'r') as f: # open file to read for line in f: # read file line by line line = line.strip() if line.startswith('We the People'): # check if the line starts with 'We the People' print(line) # if so then print the line except FileNotFoundError: # if file is not found print(filename + " does not exists!") # print an error
Get Answers For Free
Most questions answered within 1 hours.