Offset key WORD for cipher in Python
Question: So I am half way through a Computing GCSE controlled assessment at school.

I have completed task one of my controlled assessment which was to create a
Caeser Cipher which encrypts a message by offsetting each letter in the
message by a key number which the user must enter.

Task two is to do the same, but using a key WORD.

This means that the keyword string must be multiplied until it is the same
length as the message which the user enters(from part one). For example:

keyword=gcse

usersmessage= Hello, my name is Jake

The keyword must be multiplied so it looks something like this compared to the
message:

**gcsegcsegcsegcsegcsegc**

**Hello, my name is Jake**

Now the above message and key word are the same length (22 characters,
although they don't look it)

Next, each ascii value of each character must be added together, meaning the
first letter of each string is added together, then the second, then third
etc..

Until each letter of the message now has a new value, once the program has
carried out this process it will need to print the **encrypted** message onto
the screen for the user to see. Can anybody help with this? It's hard to
explain here but hopefully somebody will know what I'm on about :) The main
issue I am having is that I cannot multiply a string by a number with a
decimal place, are there any ways around this? If nobody can answer the
question please tell me how I could carry this out, thanks.


Answer: Don't use multiplying here, use
[`itertools.cycle`](https://docs.python.org/2/library/itertools.html#itertools.cycle)
together with iterating over the string:

    
    
    >>> from itertools import cycle
    >>> word = cycle('gcse')
    >>> message = 'Hello, my name is Jake'
    >>> ''.join([next(word) for c in message])
    'gcsegcsegcsegcsegcsegc'
    

