Apr-18-2017, 01:43 PM
I want to take a string and replace every letter in the string with the second to next letter in the alphabet. eg(a => c, b => d). My code changes the string does not save and will change back to the original string when changing the next letter. Thanks for any help
def fix(block): alf = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] cur = 0 old = 0 new = 2 while cur < 26: new_block = [] get = block.replace(alf[old], alf[new]) old = old + 1 new = new + 1 cur = cur + 1 return get