Question
(FOR PYTHON) Write a function, printStringStats(inputString), that takes as input a string of lowercase letters and prints three things: the lexicographically largest letter (z >
(FOR PYTHON) Write a function, printStringStats(inputString), that takes as input a string of lowercase letters and prints three things: the lexicographically largest letter (z > y > ... > a), the third largest letter, and the most common letter along with how many times it occurs. You may assume the string is at least one character long. But you may not assume that it contains at least three different characters. If fewer than three different letters appear in the string, print something appropriate for the third largest (e.g. "There is no third largest letter.") If two or more letters tie for most common, you may choose any one of them. For example:
>>> printStringStats('aaczzcqzqqqzqc') In 'aaczzcqzqqqzqc', the largest letter is 'z', the third largest letter is 'c', and the most common letter is 'q', occurring 5 times >>> printStringStats("aaaaba") In 'aaaaba', the largest letter is 'b', there is no third largest letter, and the most common letter is 'a', occurring 5 times
NOTE: you may not use built-in min, max, sort, or sorted functions. You may not use any built-in string methods. Use one or more simple loops, and simple comparison (<,>, ==, !=) operators only.
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