Caesar's Cipher using python, could use a little help

后端 未结 8 1360
时光说笑
时光说笑 2020-11-30 14:24

I\'m trying to make a \"Caesar\'s Cipher\" while using python..this is what I have so far. Could anyone tell me how this is looking? Am I going in the right direction? What

8条回答
  •  有刺的猬
    2020-11-30 15:22

    For Python 3.3, try using the ord(), chr() and .isalpha functions:

    m = input("What is your message?: ")
    s = int(input("What is the shift?: "))
    for i in m:
        if i.isalpha():
            if (ord(i)+s)>90:
                print(chr(ord(i)+s-26),end=""),
            elif chr(ord(i)+s-26)<65:
                print("The shift is invalid")
            else:
                print(chr(ord(i)+s),end=""),
        else:
            pass
    

提交回复
热议问题