Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions