Question: Using Python (Do not use regular expressions, no tuples, no methods of string, no indexing of strings : str[0] is the first character of string

Using Python (Do not use regular expressions, no tuples, no methods of string, no indexing of strings : str[0] is the first character of string str, str[1] is the second, etc.)

Write a program called CountConsecutiveChars it reads strings from the user until the user presses enter without entering anything. it reports the number of characters that appear consecutively in the string more than once (lets call that a "run") it also prints the length of the largest run. For example if the String is: "aaxbbb", then the sum of all characters that were repeated consecutively is 5 because 'a' repeats 2 times and 'b' repeats 3 times. The largest run was 3 (the b's).

% python3 CountConsecutiveChars.py  enter a string: abc >>>count 0 >>>max 0 enter a string: aabc >>>count 2 >>>max 2 enter a string: aaabc >>>count 3 >>>max 3 enter a string: aaaabcc >>>count 6 >>>max 4 enter a string: aaaaabbc >>>count 7 >>>max 5 enter a string: abcccc >>>count 4 >>>max 4 enter a string: 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve the problem as described well create a Python script that reads strings from user input and calculates both the total count of consecutive ch... View full answer

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!