Python Forum
Adding text to files easy but I need help
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding text to files easy but I need help
#1
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?
Reply
#2
So, it's easy show us the easy part
Reply
#3
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.)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Split string into 160-character chunks while adding text to each part iambobbiekings 9 9,610 Jan-27-2021, 08:15 AM
Last Post: iambobbiekings
  parse text, save individual chapters into text files isniffbooks 3 3,797 Nov-07-2019, 12:04 AM
Last Post: isniffbooks
  Adding text to plot Pythcoronas 1 2,200 Sep-13-2018, 12:27 PM
Last Post: baby_quant

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020