Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For my program I keep on getting this error Traceback (most recent call last): F

ID: 3914203 • Letter: F

Question

For my program I keep on getting this error

Traceback (most recent call last):
File "/Users/adamchristopher/Desktop/Programs/Program 9/Program9.py", line 173, in <module>
main()
File "/Users/adamchristopher/Desktop/Programs/Program 9/Program9.py", line 42, in main
annualRainfall = float(words[0])
ValueError: could not convert string to float: '{ tf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf830'
>>>

This is what the program looks like

def main():
#Open the file
inFile = open('Program9.txt', 'r')
  
lineRead = inFile.readline() # Read first record
while lineRead != '': # While there are more records
words = lineRead.split() # Split the records into substrings
annualRainfall = float(words[0])

print(allMonths(words), format(annualRainfall, '.2f'))
print('Total rainfall for the year was', format(total(words), '.2f'), 'inches')
print('Average rainfall for the year was', format(average(words), '.2f'), 'inches')
print('The highest amount of rainfall was', format(maxRain(words), '.2f'),
'inches in the month of ', allMonths(maxRain(words)))
print('The lowest amount of rainfall was', format(minRain(words), '.2f'),
'inches in the month of ', allmonths(minRain(words)))

lineRead = inFile.readline() # Read next record

# Close the file.
inFile.close() # Close file
#End of Main

Explanation / Answer

Your entire program is correct...

By getting this error, words[0] not contains float value

In Program9.txt contains, first column is not a float

If you still understood, please provide Program9.txt in comments...

I can give complete solution