# Learn String Manipulation by Building a Cipher - Step 68

**URL:** <https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-68/693634>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [June 4, 2024, 4:23am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-68/693634 "2024-06-04T04:23:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asftup](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@asftup](https://forum.freecodecamp.org/u/asftup)\
**Post date:** [June 4, 2024, 4:23am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-68/693634/1 "2024-06-04T04:23:40Z")

</div>

### Tell us what’s happening:

I added to the param, but i have avoid the errors i dont know what i have to do

### Your code so far

```py

# User Editable Region

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)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    
    return encrypted_text 
encrypted = vigenere(text, custom_key)
print(encrypted)

# User Editable Region

```

### Your browser information:

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

### Challenge Information:

Learn String Manipulation by Building a Cipher - Step 68

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

---

<div class="post-metadata">

**Author:** ![Dario\_DC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dario_dc/32/280679_2.png) [@Dario\_DC](https://forum.freecodecamp.org/u/Dario_DC)\
**Post date:** [June 4, 2024, 7:25am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-68/693634/2 "2024-06-04T07:25:07Z")

</div>

> Also, comment out the last two lines of code to avoid errors in the console.

It means you should turn the last two lines of code into comments

---

<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:** [December 3, 2024, 7:25pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-68/693634/3 "2024-12-03T19:25:28Z")

</div>

Closed on December 3, 2024, 7:25pm UTC

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