how do i add this to my python program (don’t change anything
from my original program, just add new code)
ask user to enter a 2 letter state abbreviation and then print
out all locations for that state
At the end of the list of locations for that state, print the
number of locations that are in that state
if a state abbreviation that does not exist was entered, it
should print out “does not exist”
once all of that works, make it into a function named
WhereStates. this function should accepts one value (the
state abbreviation) and prints the appropriate information.
submit function and main function
The main function asks the user for a state abbreviation and
then calls the function.
The file should open and close inside the function.
this is my python program
# function UserStates, open file read data and store state
abbreviation in list , sort and print
def UserStates():
# open file to read
file = open(“CovidResults.txt”, “r”)
# list to store state abbreviation
state_abbreviations = []
# for loop in opened file
for row in file:
# striped each row
stripped_row = row.strip()
# split row separated by comma, into
list
List = stripped_row.split(‘,’)
# at 4th indeex of List is state
abbreviation,
#so check if abbreviation has 2 char
and not already in state_abbreviation_list, for avoid
duplicates
if len(List[4]) == 2 and List[4] not in
state_abbreviations:
state_abbreviations.append(List[4])
#close file
file.close()
# sort list
state_abbreviations.sort()
#print, line by line, one in each line
print(“state abbreviations in sorted order from the
file ‘CovidResults.txt'”)
for st in state_abbreviations:
print(st)
# main function
def main():
# call UserStates function
UserStates()
#test
#call main
main()
this is the file-called – CovidResults
Date,FIPS,MMWR_week,Recip_County,Recip_State,Series_Complete_Pop_Pct,Series_Complete_Yes,Series_Complete_12Plus,Series_Complete_18Plus,Series_Complete_65Plus,Administered_Dose1_Recip,Administered_Dose1_Recip_12Plus,Administered_Dose1_Recip_18Plus,Administered_Dose1_Recip_65Plus,SVI_CTGY,Metro_status
11/14/2021,13265,46,Taliaferro
County,GA,22.1,340,340,317,94,364,364,335,97,D,Non-metro
11/14/2021,21219,46,Todd
County,KY,38.3,4705,4705,4504,1476,5282,5280,5050,1609,D,Non-metro
11/5/2021,42109,44,Snyder
County,PA,42.6,17180,17180,16395,6299,21023,21023,20111,7537,A,Non-metro
11/5/2021,18131,44,Pulaski
County,IN,41.6,5141,5141,4905,2012,5520,5520,5245,2077,A,Non-metro
11/5/2021,40045,44,Ellis
County,OK,32.3,1247,1247,1221,600,1433,1433,1403,697,B,Non-metro
7/17/2021,29195,28,Saline
County,MO,34.1,7760,7760,7642,2971,8699,8698,8493,3159,D,Non-metro
7/17/2021,27003,28,Anoka
County,MN,44.3,158041,157649,148451,39006,170625,170056,159871,40847,A,Metro
2/13/2021,31057,6,Dundy
County,NE,6,101,101,101,61,203,203,202,136,B,Non-metro
2/13/2021,49011,6,Davis
County,UT,3.2,11463,11463,11410,1525,29892,29891,29737,11235,A,Metro
12/31/2020,51071,53,Giles County,VA,0,0,0,0,0,0,0,0,0,B,Metro
12/31/2020,13259,53,Stewart
County,GA,0,0,0,0,0,0,0,0,0,D,Non-metro
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more