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

后端 未结 8 1404
时光说笑
时光说笑 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:11

    I like kaizer.se's answer, but I think I can simplify it using the string.maketrans function:

    import string
    
    first = raw_input("Please enter Plaintext to Cipher: ")
    k = int(raw_input("Please enter the shift: "))
    
    shifted_lowercase = ascii_lowercase[k:] + ascii_lowercase[:k]
    
    translation_table = maketrans(ascii_lowercase, shifted_lowercase)
    
    print first.translate(translation_table)
    

提交回复
热议问题