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
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