word ladder in python
- by user365523
I'm trying to create a word ladder program in python. I'd like to generate words that are similar to a given word. In c++ or java, I would go through each valid index in the original string, and replace it with each letter in the english alphabet, and see if the result is a valid word. for example (pseudocode)
for (int i = 0; i < word.length(); i++) {
for (every character c in the alphabet) {
change the letter of word at index i to be c.
if the result is a valid word, store it in a list of similar words
}
}
.
However, this doesn't seem like a very "python" way of doing things. How would I approach this problem in python?