Question: Write this program using Python 3: You are given a text file containing 3 types of data - actions(a), commands(c), and results(r). Each action or
Write this program using Python 3:
You are given a text file containing 3 types of data - actions(a), commands(c), and results(r). Each action or command will be followed by a result. Parse through the input.txt file and store the 3 types of data in lists, then create an output.txt file in the format displayed below. The program should be able to handle any amount of data provided and always produce an output file in the proper order.
1. Your program must test to make sure that every action or command has a corresponding result afterwards or the program should not create an output file, and instead print out an error message! 2. Your program must be able to produce the actions/commands and results in the order they were received. In this example it goes action, result, command, result, command, result, action, result. Listing them as action, result, action result, command, result, command, result IS WRONG.
INPUT.TXT a:running r:become tired
c:go run r:begin running
c:go climb r:begin climbing
a:jumping r:legs hurt
EXPECTED OUTPUT.TXT
action:running result:become tired
command:go run result:begin running
command: go climb result:begin climbing
action:jumping result:legs hurt
command:go swim result:swimming
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
