Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your friend wants to try to make a word ladderl This is a list of words where each word has a one - letter difference
Your friend wants to try to make a word ladderl This is a list of words where each word has a oneletter difference from the word before it Here's an example: cat cot cog log Write a program to help your friend. It should do the following: Ask your friend for an initial word Repeatedly ask them for an index and a letter You should replace the letter at the index they provided with the letter they enter You should then print the new word Stop asking for input when the user enters for the index Here's what should be happening behind the scenes: You should have a function, get index, that repeatedly asks the user for an index until they enter a valid integer that is within the acceptable range of indices for the initial string. If they enter a number out of range, you should reply invalid index. You should have another function, get letter, that repeatedly asks the user for a letter until they enter exactly one lowercase letter. If they enter more than one character, you should reply Must be exactly one character!. If they enter a capital letter, you should reply Character must be a lowercase letter! You should store a list version of the current word in a variable. This is what you should update each time the user swaps out a new letter. Each time you have to print the current word, print the string version of the list you are keeping in you variable. Here's what an example run of your program might look like: Enter a word: cat Enter an index to quit: Enter a letter: o cot Enter an index to quit: Enter a letter: g cog Enter an index to quit: Invalid index Enter an index to quit: Invalid index Enter an index to quit: Enter a letter: L character must be a lowercase Letter Enter a letter: log Enter an index to quit:
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