In: Computer Science
Write a Python program in a file called consonants.py, to solve the following problem using a nested loop. For each input word, replace each consonant in the word with a question mark (?). Your program should print the original word and a count of the number of consonants replaced. Assume that the number of words to be processed is not known, hence a sentinel value (maybe "zzz") should be used. Sample input/output:
Please enter a word or zzz to quit: Dramatics
The original word is: dramatics
The word without consonants is: ??a?a?i??
The number of consonants in the word are: 6
Please enter another word or zzz to quit: latchstring
The original word is: latchstring
The word without consonants is: ?a??????i??
The number of consonants in the word are: 9
Please enter another word or zzz to quit: YELLOW
The original word is: yellow
The word without consonants is: ?e??o?
The number of consonants in the word are: 4
Please enter another word or zzz to quit: zZz
Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. Thank You !! ================================================================================ while True: word = input('Please enter a word or zzz to quit: ').lower() if word == 'zzz': break else: count = 0 modified = '' for letter in word: found = False for consonant in 'bcdfghjklmnpqrstvwxyz': if letter == consonant: modified += '?' count += 1 found = True break if found is not True: modified += letter print('The original word is: {}'.format(word)) print('The word without consonants is: {}'.format(modified)) print('The number of consonants in the word are: {}'.format(count))