# Learn String Manipulation by Building a Cipher - Step 75

**URL:** <https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [January 2, 2024, 7:31am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370 "2024-01-02T07:31:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlon.kuhnreich](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/marlon.kuhnreich/32/347023_2.png) [@marlon.kuhnreich](https://forum.freecodecamp.org/u/marlon.kuhnreich)\
**Post date:** [January 2, 2024, 7:31am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/1 "2024-01-02T07:31:55Z")

</div>

### Tell us what’s happening:

I modified the line:  
if char.isalpha() == ’ ':

to:  
if not char.isalpha():

My code is working in the console but it’s still not passing the step.  
This is my first time using freeCodeCamp and I’m not finding the tips very helpful at all. I understand the need to search for answers, but these are the very basics of a new topic and I find it’s not doing a good job at teaching me what to do nor teaching me what I did wrong.

### Your code so far

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

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

    for char in message.lower():

/* User Editable Region */

        # Append space to the message
        if not char.isalpha():
            final_message += char

/* User Editable Region */

        else:        
            # Find the right key character to encode/decode
            key_char = key[key_index % len(key)]
            key_index += 1

            # Define the offset and the encrypted/decrypted letter
            offset = alphabet.index(key_char)
            index = alphabet.find(char)
            new_index = (index + offset*direction) % len(alphabet)
            final_message += alphabet[new_index]
    
    return final_message
    
encryption = vigenere(text, custom_key)
print(encryption)
decryption = vigenere(encryption, custom_key, -1)
print(decryption)

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15`

### Challenge Information:

Learn String Manipulation by Building a Cipher - Step 75

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-75)**
>
> 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:** [January 2, 2024, 8:53am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/2 "2024-01-02T08:53:31Z")

</div>

Hey, I know this might seem counterintuitive if you understand what you are doing. The hint suggests that the condition should be `char.isalpha()`. This is because the `not` operator has not been introduced yet. You will add it in a second moment. Hope this is helpful.

---

<div class="post-metadata">

**Author:** ![marlon.kuhnreich](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/marlon.kuhnreich/32/347023_2.png) [@marlon.kuhnreich](https://forum.freecodecamp.org/u/marlon.kuhnreich)\
**Post date:** [January 2, 2024, 5:17pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/3 "2024-01-02T17:17:04Z")

</div>

Thanks for the reply. The problem is I only know very little.  
It’s counterintuitive because either I know too much and can’t pass, or don’t know enough to understand the hints and can’t pass.

So right now it’s frustrating that I’d like to move on and continue learning, but I’m stuck here because I’m trying to think of the correct ‘wrong’ answer to give.

I tried:

if char.isalpha() == False

And that didn’t work either. I’m completely at a loss as to what FCC expects me to change the if statement to!

---

<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:** [January 2, 2024, 5:44pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/4 "2024-01-02T17:44:27Z")

</div>

> Modify the `if` condition by calling `.isalpha()` on `char`.

You’re very close. Sometimes, it helps to follow the instructions to the letter instead of trying to interpret the logic. You’ve done as instructed, but step doesn’t mention anything about checking if `.isalpha()` is `False`.

---

<div class="post-metadata">

**Author:** ![HungryBee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hungrybee/32/345970_2.png) [@HungryBee](https://forum.freecodecamp.org/u/HungryBee)\
**Post date:** [January 2, 2024, 5:48pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/5 "2024-01-02T17:48:30Z")

</div>

Hello marlon,

Don’t worry, as long as you keep your motivation you will keep learning. I am going to answer this question with your code from the first post in mind.

As the question describes: `.isalpha()` method returns `True` if all the character of the string on which it is called are letters. Meaning that if you did `'freeCodeCamp'.isalpha()` it would return. Therefore if you had an if statement as followed:

```auto
if 'freeCodeCamp'.isalpha():
    print ('It worked!')

```

It would print the text because every character in the string is a letter.

Back to the question, ignore the comment that is above the code. We’re only going to change the if statement to see if `.isalpha()` on `char` returns `True `or not.

---

<div class="post-metadata">

**Author:** ![marlon.kuhnreich](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/marlon.kuhnreich/32/347023_2.png) [@marlon.kuhnreich](https://forum.freecodecamp.org/u/marlon.kuhnreich)\
**Post date:** [January 3, 2024, 12:12am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/6 "2024-01-03T00:12:48Z")

</div>

Finally got it.

Thanks for your help!  
It’s difficult to stay motivated when things get frustrating like the minutiae of the site.

---

<div class="post-metadata">

**Author:** ![HungryBee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hungrybee/32/345970_2.png) [@HungryBee](https://forum.freecodecamp.org/u/HungryBee)\
**Post date:** [January 3, 2024, 2:16pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/7 "2024-01-03T14:16:37Z")

</div>

That’s understandable, but we’re all here for you during those times! 😊

---

<div class="post-metadata">

**Author:** ![amorosmanuel](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@amorosmanuel](https://forum.freecodecamp.org/u/amorosmanuel)\
**Post date:** [January 5, 2024, 9:38pm UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/8 "2024-01-05T21:38:44Z")

</div>

You’re not alone! It’s frustrating as hell but that’s what makes the struggle beautiful when we succeed. Carry on the good work boss!

---

<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 6, 2024, 9:38am UTC](https://forum.freecodecamp.org/t/learn-string-manipulation-by-building-a-cipher-step-75/660370/9 "2024-07-06T09:38:51Z")

</div>

Closed on July 6, 2024, 9:38am UTC

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