Question: 21. (+20) Write a python program that: Ask the user for a string and creates the following dictionary: The values are the letters in the

 21. (+20) Write a python program that: Ask the user for

a string and creates the following dictionary: The values are the letters

in the string, with the corresponding key being the place in the

string. For example if the user entered the string "CSC120" then create

the dictionary d a. b. Display the length of the dictionary d

21. (+20) Write a python program that: Ask the user for a string and creates the following dictionary: The values are the letters in the string, with the corresponding key being the place in the string. For example if the user entered the string "CSC120" then create the dictionary d a. b. Display the length of the dictionary d In this case it is 6 Ask the user for a key(integer). If the key is in the dictionary display the corresponding value. As an example if the user entered 2 display 'C, if the user entered a key that was not in the dictionary display "Error key not found" Ask the user for a value (one of the characters). If the value is in the dictionary display Value found" otherwise display "Value not found". As an example if the user entered?display "value found" Ask the user for a string of digits, separated by a comma. Print out the corresponding values for those digits. For example if the user enters the string "0,1, 4" then print out 'C 'S' '2' (or "CS2") At issue is how to handle out of range digits for example, in our case, any digits in the range 0...5 should generate a corresponding value but any digit(s)> 5 OR

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!