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
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
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!