Programming in Python; writing a Caesar Cipher using a zip() method

Posted by user1068153 on Stack Overflow See other posts from Stack Overflow or by user1068153
Published on 2011-11-28T01:30:59Z Indexed on 2011/11/28 1:50 UTC
Read the original article Hit count: 180

Filed under:

I'm working on a python program for homework and the problem asks me to develop a program that encrypts a message using a caesar cipher. I need to be able to have the user input a number to shift the encryption by, such as 4: e.g. 'A' to 'E'. The user also needs to input the string to be translated. The book says to use a zip() to do the problem. I am confused on how I would do this though.

I have this but it doesn't do anything

>>>def ceasarCipher(string, shift):
    strings = ['abc', 'def']
    shifts = [2,3]
    for string, shift in zip(strings, shifts):

        print ceasarCipher(string,shift)


>>>string = 'hello world'
>>>shift = 1

© Stack Overflow or respective owner

Related posts about homework