Page 1 of 1

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
by answerhappygod
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”.
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 1
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 1 (25.98 KiB) Viewed 55 times
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