Create a script named "sort.py" that requires exactly one
command line argument, which is the name of a file that contains
numbers (one number per line).
Read the numbers from the file into a list of floats, using a
list comprehension. Sum the list of numbers, sort the list of
numbers, and write the sorted list out to a file named
"sorted.txt".
Display the original list and sum to the console:
Use try/except to print error messages when 1) the input file is
not found or 2) when the data is not in the proper format (one
number per line).
The output file should have all of the same numbers as the input
file, but in sorted order.
{simple code:}
Create a script named "sort.py" that requires exactly one command line argument, which is the name of a file that contai
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Create a script named "sort.py" that requires exactly one command line argument, which is the name of a file that contai
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!