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 (maybe in a dictionary as 3 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. Your test must 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!
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
