Answered step by step
Verified Expert Solution
Link Copied!

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 one-letter 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 -1 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 (-1 to quit): 1 Enter a letter: o cot Enter an index (-1 to quit): 2 Enter a letter: g cog Enter an index (-1 to quit): 5 Invalid index Enter an index (-1 to quit): -3 Invalid index Enter an index (-1 to quit): 0 Enter a letter: L character must be a lowercase Letter Enter a letter: 1 log Enter an index (-1 to quit): -1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

Classify delivery styles by type.

Answered: 1 week ago