The code below prints all the lines that have a city that starts with an “A”. Change it so that it prints out all lines
Posted: Fri May 20, 2022 5:26 pm
The code below prints all the lines that have a city that starts
with an “A”. Change it so that it prints out all lines that have a
city that starts with “A” or “B”.
Save & Run Load History 1 # read all the lines 2 inFile = open("uspoll.txt","r") 3 lines = infile.readlines() 4 inFile.close() 5 6 # loop through the lines 7 for line in lines: if line[0] == "A": 9 print(line) 10 8
with an “A”. Change it so that it prints out all lines that have a
city that starts with “A” or “B”.
Save & Run Load History 1 # read all the lines 2 inFile = open("uspoll.txt","r") 3 lines = infile.readlines() 4 inFile.close() 5 6 # loop through the lines 7 for line in lines: if line[0] == "A": 9 print(line) 10 8