Question: Write a program in python that reads values from an input file data.txt and store them in a list T1, then fills another list T2

Write a program in python that reads values from an input file data.txt and store them in a list T1, then fills another list T2 with values from T1 where any consecutive duplicated values appears only one time, i.e. removes consecutive duplicated values. If you run your program with the following input data: 4 7 3 3 3 6 14 14 10 5 7 7 7 7 2 2 9 9 9 10. Your output should be as follows:

Number of elements in T1: 20

T1: 7 3 3 3 6 14 14 10 5 7 7 7 7 2 2 9 9 9 10

Number of elements in T2: 11

T2: 4 7 3 6 14 10 5 7 2 9 10

Your program should have at least these 3 functions:

main(): displays the original list T1, the number of elements of T2 and list T2

readData():reads data from input file into a list

removeConsecutiveDuplicates(): take a list and remove any consecutive duplicated numbers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!