Suppose the following problem statement is given to you and you are planning to write a code for this problem. Problem statement: Let str be a string that contains any number of lower case letters from this set {a, b, c, .. z}. Samples of some valid str's are aabddd, bttttccd, cafffffgggaat etc. Your program must validate the input (check whether it contains only lowercase letters) and create and print a new string (a copy of str) such that all repeated letters in str are replaced by the number of repeats followed by just one letter, i.e., aa will be replaced by 2a, bbb will be replaced by 3b, etc. Other (non-repeated) letters will remain same
Suppose the following problem statement is given to you and you are planning to write a code for this problem.
Problem statement:
Let str be a string that contains any number of lower case letters from this set {a, b, c, .. z}. Samples of some valid str's are aabddd, bttttccd, cafffffgggaat etc.
Your program must validate the input (check whether it contains only lowercase letters) and create and print a new string (a copy of str) such that all repeated letters in str are replaced by the number of repeats followed by just one letter, i.e., aa will be replaced by 2a, bbb will be replaced by 3b, etc. Other (non-repeated) letters will remain same, For invalid inputs your program must generate an error message.
Some sample strings and the expected outputs are as follows.
Sample str = aabddd, expected output = 2ab3d
Sample str = bttttccd, expected output = b4t2cd
Sample str = caffgggaat, expected output = ca2f3g2at
Sample str = caffgggaat, expected output = ca2f3g2at
Sample str = dddccaaaaefg, expected output = 3d2c4aefg
Sample str = bdcagt, expected output = bdcagt
Recall that there are four elements of the computational thinking process that we should apply to solve a given problem. Mention the name of each element and then briefly describe how you will apply that element to solve this problem. Note, you do not have to write a python code for this problem.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)