Help with CodeHS 6.2.15

Im trying to make a word ladder:

Your friend wants to try to make a word ladder! 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. You should have another function, get_letter, that repeatedly asks the user for a letter until they enter exactly one 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 your 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 Enter an index (-1 to quit): -3 Enter an index (-1 to quit): 0 Enter a letter: L Enter a letter: l log Enter an index (-1 to quit): -1

heres my code:

https://pastebin.com/dA2b2gHu

please help

i need help with that the variable isnt recognized outside of the program. Also i can solve it but when it keeps asking for new word variable and I dont want it to.

Posted Aug 17, 2017, 8:06 PM UTC · edited

11
Loading comments…