谁能帮我找出问题所在?我的代码中的索引错误

Can anyone help me find out what's wrong? Index error in my code

我正在 Python 中编写一个非常粗糙的凯撒密码,它可以很好地处理简单的消息,但是当我输入完整的字母表时,我在第 16 行出现错误,说有一个索引错误:字符串索引超出范围。谁能帮我找出问题所在?这是我的代码:

    abc = "ABCDEFGHIJKLMNOPQRTUVWXYZ"
    m = str(input("Message: "))
    m = m + "~"
    m_t = m.index("~")
    o = int(input("Offset: "))
    e_m = "Encrypted Message: "
    for loop_counter in range(m_t):
        c = m[loop_counter]
        if c in abc:
            p = abc.index(c)
            p = p + o
            if 25 < p:
                p = p - 26
            elif 0 > p:
                p = p + 26
            n_c = abc[p]
            e_m = e_m + n_c
        else:
            e_m = e_m + c

    print(e_m)

您的 'abc' 字符串长度为 25,您错过了 "S" 字母...