Question
Question: Write a python script that will read in the attached file (input.txt), swap the two columns, and print them back out. See attached outfile.txt
Question: Write a python script that will read in the attached file (input.txt), swap the two columns, and print them back out. See attached outfile.txt for an example.
Hints: You can use the read line method to return the whole line of text. What you will find is that the line is a list type. The list type is what we would think of as an array in C++. So strings are in some way the same handled the same in Python as C++.
(input.txt) First,Last Bill,Logger Hannah,Flowers Bob,Cratchet Chris,Craft Tom,Thumb Fred,Bird Stephen,Stone Ashley,Stone
(outfile.txt) (Expected Answer) Last,First Logger,Bill Flowers,Hannah Cratchet,Bob Craft,Chris Thumb,Tom Bird,Fred Stone,Stephen Stone,Ashley
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started