Python Forum

Full Version: Adding text to files easy but I need help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Given a file containing test scores, one per line, we want to have a new file that contains the scores in increasing order. To do this, write a Python program that asks the user for two file name strings, one for the input scores and the second for the output, sorted scores. The program should open the first file (to read), read the scores, sort them, open the second file (to write), and output to this file the scores in increasing order. There should be one score per line, with the index on each line.


I am unsure of what to do? Can someone help me?
So, it's easy show us the easy part
You already have a nice description of the necessary steps in the task.
Now, search for the appropriate commands: what to use for user input, file handling (opening and closing, reading from and writing to), for sorting what you got from file reading, and a bit of string handling (if I understand the last sentence correctly).

Then, try to connect them in a good order, and get rid of all error messages. This last part usually is the not-so-easy one... but we will help, if we can. (And 'can' includes code proposals from you.)