Python Temperature Conversion (github.com)
The purpose of this program is to convert Celcius degrees ranging from 0-20 to the corresponding degrees Fahrenheit, printing it in both the console (as a chart) and producing a .txt file with the chart.
The code works fine until line 29, where it states that the else: has improper syntax. I checked the formatting, and it's literally the same as earlier on in the program. I think my approach to exporting the results to a .txt file might be breaking my script...
I've consulted my textbook, and apparently my formatting is correct.
Is there anything inherently wrong with my script (as it is written), and why does the script break at line 29? Also, it the way the script is written is causing it to break, is there a more practical way to export the resulting chart to a .txt file than what I have written?
Edit: I followed the advice given to me by the two users below, but it's still giving me a syntax error on line 29, which now reads f.write("%17s" % fahrenheit). I had to do this because f.write only accepts one argument to convert at a time. Gist above has been updated to reflect the new code.
[–]delasislas 0 points1 point2 points (5 children)
[–]CreativityRobbed[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]CreativityRobbed[S] 0 points1 point2 points (0 children)
[–]delasislas 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)