# Learn String Manipulation by Building a Cipher - Step 38

**URL:** <https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [January 1, 2024, 4:41pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207 "2024-01-01T16:41:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gjangir500](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gjangir500](https://forum.freecodecamp.org/u/gjangir500)\
**Post date:** [January 1, 2024, 4:41pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/1 "2024-01-01T16:41:51Z")

</div>

### Tell us what’s happening:

Describe your issue in detail here.

### Your code so far

```py

/* User Editable Region */

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

for char in text.lower():
    if <char == ' '>:
    print(space!)
    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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36`

### Challenge Information:

Learn String Manipulation by Building a Cipher - Step 38

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-38)**
>
> 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:** [January 1, 2024, 4:41pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/2 "2024-01-01T16:41:51Z")

</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:** ![sampsoninyang](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@sampsoninyang](https://forum.freecodecamp.org/u/sampsoninyang)\
**Post date:** [January 1, 2024, 5:00pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/3 "2024-01-01T17:00:04Z")

</div>

> [@gjangir500](#):
>
> ```auto
> if <char == ' '>:
> print(space!)
> 
> ```

your code have two problems .  
**first** remove \<\> as it is not required.  
**Second** your indentation of your print() is not right. 💪 happy coding.

---

<div class="post-metadata">

**Author:** ![gjangir500](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gjangir500](https://forum.freecodecamp.org/u/gjangir500)\
**Post date:** [January 2, 2024, 2:46pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/4 "2024-01-02T14:46:27Z")

</div>

what should i do now

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

for char in text.lower():
    if char== ' ':
        encrypted_text+=''
        print('space!')

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

```

---

<div class="post-metadata">

**Author:** ![sampsoninyang](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@sampsoninyang](https://forum.freecodecamp.org/u/sampsoninyang)\
**Post date:** [January 2, 2024, 2:59pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/5 "2024-01-02T14:59:18Z")

</div>

> [@gjangir500](#):
>
> for char in text.lower():  
> if char== ’ ‘:  
> encrypted\_text+=’’  
> print(‘space!’)

you have missed two level of indentation.  
first after the for loop  
second after the if statement.

---

<div class="post-metadata">

**Author:** ![abdulbosit19980204](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/abdulbosit19980204/32/346402_2.png) [@abdulbosit19980204](https://forum.freecodecamp.org/u/abdulbosit19980204)\
**Post date:** [January 2, 2024, 3:09pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/6 "2024-01-02T15:09:11Z")

</div>

Please pay attention! If statement!

1. Remove the \<\> character  
char==’ ’
2. and add space after if and add string symbol ‘’ for space!  
if char==’ ':  
print(‘space!’)

---

<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:** [January 2, 2024, 3:11pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/7 "2024-01-02T15:11:20Z")

</div>

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (').

---

<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:** [July 3, 2024, 3:11am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-38/660207/8 "2024-07-03T03:11:58Z")

</div>

Closed on July 3, 2024, 3:11am UTC

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