请问各位这个怎么解决啊,要求使用for循环

img


是用for循环把每个字符转换成ASCII吗?
然后给每个码加上字符的下标,最后转成字符吗?
感觉思路有一点点了,但具体怎么写还不明白

def encrypt_string(string):
    result = ""
    for i, c in enumerate(string):
        # 计算新的ascii码值
        ascii_value = ord(c) + i
        # 判断ascii码是否超出字母范围,是则减去26
        if c.islower() and ascii_value > ord('z'):
            ascii_value -= 26
        elif c.isupper() and ascii_value > ord('Z'):
            ascii_value -= 26
        result += chr(ascii_value)
    return result
a = input("输入字符串(只能是字母)")
b = encrypt_string(a)
print("加密后是 ", b)