# Learn String Manipulation by Building a Cipher - Step 71

**URL:** <https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-71/780160>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [February 25, 2026, 8:02am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-71/780160 "2026-02-25T08:02:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martina\_Soliman](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@Martina\_Soliman](https://forum.freecodecamp.org/u/Martina_Soliman)\
**Post date:** [February 25, 2026, 8:02am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-71/780160/1 "2026-02-25T08:02:43Z")

</div>

### Tell us what’s happening:

I don’t know how to solve it , so could you please help me ? thanks in advance

### Your code so far

```py
text = 'Hello Zaira'
custom_key = 'python'

def vigenere(message, key, direction):
    key_index = 0
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''

    for char in message.lower():
    
        # Append space to the message
        if char == ' ':
            encrypted_text += char
        else:        
            # Find the right key character to encode
            key_char = key[key_index % len(key)]
            key_index += 1

            # Define the offset and the encrypted letter
            offset = alphabet.index(key_char)
            index = alphabet.find(char)

# User Editable Region

            new_index = offset * direction

# User Editable Region

            encrypted_text += alphabet[new_index]
    
    return encrypted_text
    
encryption = vigenere(text, custom_key ,1)
print(encryption)

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36`

### Challenge Information:

Learn String Manipulation by Building a Cipher - Step 71

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-71)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![a1legalfreelance](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/a1legalfreelance/32/385700_2.png) [@a1legalfreelance](https://forum.freecodecamp.org/u/a1legalfreelance)\
**Post date:** [February 25, 2026, 8:09am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-71/780160/2 "2026-02-25T08:09:09Z")

</div>

> [@Martina\_Soliman](#):
>
> [https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-71](https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-71)

Hi. You have deleted the existing seed code when you need to add to it. I suggest you reset the step and try again, carefully following the instructions.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [March 25, 2026, 8:09am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-71/780160/3 "2026-03-25T08:09:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
