The reason why it didn't work before is during your for loop you are mutating word which means that it will skip over an iteration whenever you delete something because that deletion resulted in each letter moving up a position.
Here is what the above code is Doing:
1. It’s creating a list of all the letters in the alphabet.
2. It’s creating a list of all the letters in the alphabet in reverse order.
3. It’s creating a list of all the letters in the alphabet in reverse order, but with the first letter removed.
4. It’s creating a list of all the letters in the alphabet in reverse order, but with the first and second letters removed.
5. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, and third letters removed.
6. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, and fourth letters removed.
7. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, and fifth letters removed.
8. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, and sixth letters removed.
9. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, and seventh letters removed.
10. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, and eighth letters removed.
11. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, and ninth letters removed.
12. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, and tenth letters removed.
13. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, and eleventh letters removed.
14. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, and twelfth letters removed.
15. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, and thirteenth letters removed.
16. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, and fourteenth letters removed.
17. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, and fifteenth letters removed.
18. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, and sixteenth letters removed.
19. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, and seventeenth letters removed.
20. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, and eighteenth letters removed.
21. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, eighteenth, and nineteenth letters removed.
22. It’s creating a list of all the letters in the alphabet in reverse order, but with the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, eighteenth,