The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Use Python 3.6 to create a program called CountConsecutiveChars
Â
1. it reads strings from the user until the user presses enter without entering anything.
2. it reports the number of characters that appear consecutively in the string more than once (lets call that a "run")
3. 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).
Â
You cannot use topics we haven't covered yet. For instance, in this case you cannot use indexing of strings (chapter 10). For example: str[0] is the first character of string str, str[1] is the second, etc.
Â
Note: This is chapter 7. We cannot use anything pass chapter 7 from the book. Python book has been attached. Please test project using CountConsecutiveChars_Test.py to make sure it passes all the test.
Â
Examples of runs:
% 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:
Attachments:
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly