Topics: User-defined functions, list, string, docstring Problem Statement: This program finds the unique letters from a given string and prints the unique letters and their count. For example: word ‘LITTLE’ has ‘L’, ‘I’, ‘T’, ‘E’ are the unique letters. Lab Scenario: The program repeats until hits ‘n’. The program takes a user input of a string. The program finds the unique letters in the string, add them in a list and displays the list and their count. Consider the following important points: 1) You need to design a user-defined function named count_unique_letters which takes user word as parameter and returns the list of unique letters called unique_letters in the given word. a. Hint: Iterate over each letter in user word, check if the letter is in the list, if not add it to the list, otherwise continue to the next letter. A ‘in’ keyword can help to determine if a character in the unique_letters list. b. You need to write a simple docstring for this function. 2) Your program must have a main() function. Function main() designs user menu, should take user input, call the count_unique_letters function and then prints the list returned by the function along with the count of unique letters. You need to consider using a for loop for printing the unique_letters list to get full points. a. No need to write docstring for main function b. Consider a while loop to take user word as long as user do not hit ‘n’. 3) A sample I/O is provided below. Submission: 1. All submission will be via BlackBoard during the lab time 2. Due is mentioned in the above. 3. You can take help from the GTA and have group discussion but cannot copy codes. 4. The codes need to be written in the firstname_lastname_LA6.py file. Please change the name of the file and the header of the file. Sample input/output: (Font color black indicates user input) Enter a word to start with : little little has following unique letters l--i--t--e— Count : 4 Do you want to continue (y/n): y Enter a word to start with : computer computer has following unique letters c--o--m--p--u--t--e--r— Count : 8 Do you want to continue (y/n): y Enter a word to start with : google google has following unique letters g--o--l--e— Count : 4 Do you want to continue (y/n): n >>>

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Topics: User-defined functions, list, string, docstring
Problem Statement: This program finds the unique letters from a given string and prints
the unique letters and their count. For example: word ‘LITTLE’ has ‘L’, ‘I’, ‘T’, ‘E’ are the
unique letters.
Lab Scenario:
The program repeats until hits ‘n’. The program takes a user input of a string. The program
finds the unique letters in the string, add them in a list and displays the list and their count.
Consider the following important points:
1) You need to design a user-defined function named count_unique_letters which
takes user word as parameter and returns the list of unique letters called
unique_letters in the given word.
a. Hint: Iterate over each letter in user word, check if the letter is in the list, if not
add it to the list, otherwise continue to the next letter. A ‘in’ keyword can help
to determine if a character in the unique_letters list.
b. You need to write a simple docstring for this function.
2) Your program must have a main() function. Function main() designs user menu, should
take user input, call the count_unique_letters function and then prints the list
returned by the function along with the count of unique letters. You need to consider
using a for loop for printing the unique_letters list to get full points.
a. No need to write docstring for main function
b. Consider a while loop to take user word as long as user do not hit ‘n’.
3) A sample I/O is provided below.
Submission:
1. All submission will be via BlackBoard during the lab time
2. Due is mentioned in the above.
3. You can take help from the GTA and have group discussion but cannot copy codes.
4. The codes need to be written in the firstname_lastname_LA6.py file. Please change
the name of the file and the header of the file.
Sample input/output: (Font color black indicates user input)
Enter a word to start with : little
little has following unique letters
l--i--t--e—
Count : 4
Do you want to continue (y/n): y
Enter a word to start with : computer
computer has following unique letters
c--o--m--p--u--t--e--r—
Count : 8
Do you want to continue (y/n): y
Enter a word to start with : google
google has following unique letters
g--o--l--e—
Count : 4
Do you want to continue (y/n): n
>>>

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning