def fix_place_string(s):à str i. The parameter is s, a string. Every county name ends with the places; if it correctly ends in places, do nothing (simply return s) otherwise correct the ending word to be place. Specifically, if not fix it
CodePudding user response:
def fix_county_string():
""" Insert Docstring """
fp = open("michigan_COVID_08_24_21.txt", "r")
s = ''
for line in fp:
county = line[24:43]
x = county.split()
t = x.pop(-1)
x.append("County")
s =line ' '.join(x)
return s
s = fix_county_string()
I think this is what you are trying to do you can write back the output in a file.