美文网首页
c05ex07.py

c05ex07.py

作者: 特丽斯纳普 | 来源:发表于2018-03-30 20:31 被阅读0次
# c05ex07.py
#    Caesar cipher (non-circular)

def main():
    print("Caesar cipher")
    print()

    key = int(input("Enter the key value: "))
    plain = input("Enter the phrase to encode: ")
    cipher = ""
    for letter in plain:
        cipher = cipher + chr(ord(letter) + key)

    print("Encoded message follows:")
    print(cipher)

main()

相关文章

网友评论

      本文标题:c05ex07.py

      本文链接:https://www.haomeiwen.com/subject/bxqwcftx.html