how can I move a list index value forward 'x' amount of times using python?
<p>I'm trying to unscramble a code using pythonic methods. The way to crack the code is by selecting the letter two places ahead of itself.</p>

<p>For example if the code was</p>

<pre><code>abc
</code></pre>

<p>Then the solution would be</p>

<pre><code>cde
</code></pre>

<p>So I am trying to figure out how I add 2 to the index value of a letter (given it is in a list like the following)</p>

<pre><code>alphabet = ["a","b","c"...."z"]
</code></pre>

<p>I am trying to write code similar to this</p>

<pre><code>def scramble(sentence):
    alphabet = ["a","b","c"...]
    solution = []
    for i in sentence:
        newIndex = get index value of i, += 2
        newLetter = translate newIndex into the corresponding letter
        solution.append(newLetter)
    for i in solution:
        print(i, end="")
</code></pre>

<p>But I am not yet skilled enough in python to figure it out</p>

<p>Something like this would be useful because it would allow you to change your offset value easily. It'll also handle things other than characters</p>

<pre><code>def caesar_cipher(sentence, offset):
   pt_alphabet = ['a','b'...'z']
   ct_alphabet = []
   index = len(pt_alphabet) + offset
   while len(ct_alphabet) &lt; len(pt_alphabet):
      if index &lt; (len(pt_alphabet) - 1):
         ct_alphabet.append(pt_alphabet[index])
         index += 1
      else:
         index -= len(pt_alphabet)
   out_word = ''
   for character in sentence:
      if character.lower() not in pt_alphabet:
         out_word += character
      if character.lower() in pt_alphabet:
         out_word += ct_alphabet[pt_alphabet.index(character.lower())]
   return out_word

if __name__ == '__main__':
   offset = 2
   sentence = "This is a test with caps and special characters!!"
   cipher_text = caesar_cipher(sentence, offset)
   print sentence
   print cipher_text
</code></pre>

<p>Usage like this:</p>

<pre><code>$ python cipher.py
&gt;&gt; This is a test with caps and special characters!!
&gt;&gt; vjku ku c vguv ykvj ecru cnf urgekco ejctcevgtu!!
</code></pre>

python