# Learn String Manipulation by Building a Cipher - Step 41

**URL:** <https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [February 21, 2024, 6:19am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964 "2024-02-21T06:19:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skot\_01](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@Skot\_01](https://forum.freecodecamp.org/u/Skot_01)\
**Post date:** [February 21, 2024, 6:19am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/1 "2024-02-21T06:19:39Z")

</div>

### Tell us what’s happening:

Need to compare char and space (‘’) using == operations, I tried but code not getting pass through

### Your code so far

```py

# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
    print(char == '')
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += alphabet[new_index]
     print('char:',char,'encrypted text:',encrypted_text)

# User Editable Region

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36`

### Challenge Information:

Learn String Manipulation by Building a Cipher - Step 41

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

---

<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:** [February 21, 2024, 6:19am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/2 "2024-02-21T06:19:40Z")

</div>

You appear to have created this post without editing the template. Please edit your post to **Tell us what’s happening** in your own words.

---

<div class="post-metadata">

**Author:** ![Skot\_01](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@Skot\_01](https://forum.freecodecamp.org/u/Skot_01)\
**Post date:** [February 21, 2024, 6:39am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/3 "2024-02-21T06:39:11Z")

</div>

### Tell us what’s happening:

At the beginning of your loop body, print the result of comparing `char` with a space (`' '` ). Use the equality operator `==` for that. I have tired but code doesn’t pass through.. kindly help

### Your code so far

```py

# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
    print(char == '')
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += alphabet[new_index]
     print('char:',char,'encrypted text:',encrypted_text)

# User Editable Region

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36`

### Challenge Information:

Learn String Manipulation by Building a Cipher - Step 41

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

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 21, 2024, 8:51am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/4 "2024-02-21T08:51:39Z")

</div>

> [@Skot\_01](#):
>
> `'')`

this is not a space, you need to write a space between the quotes for the string to contain a space

---

<div class="post-metadata">

**Author:** ![Silver\_fang786](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/silver_fang786/32/356065_2.png) [@Silver\_fang786](https://forum.freecodecamp.org/u/Silver_fang786)\
**Post date:** [March 4, 2024, 5:06pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/5 "2024-03-04T17:06:04Z")

</div>

try :- print(‘char is space:’,char == ’ ').

hope it will work, i got my output but it still throw error.

---

<div class="post-metadata">

**Author:** ![pkdvalis](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/pkdvalis/32/350571_2.png) [@pkdvalis](https://forum.freecodecamp.org/u/pkdvalis)\
**Post date:** [March 4, 2024, 5:29pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/6 "2024-03-04T17:29:33Z")

</div>

Please open a new topic for your question, thanks!

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the **Ask for Help** button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The **Ask for Help** button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

---

<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:** [September 3, 2024, 5:30am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-41/673964/7 "2024-09-03T05:30:11Z")

</div>

Closed on September 3, 2024, 5:30am UTC

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