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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post 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 53 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply