Learn String Manipulation by Building a Cipher - Step 80

Tell us what’s happening:

Describe your issue in detail here.
In step #80, am stuck as it states for the code, the problem-statement is:
The not operator is used to negate an expression. When placed before a truthy value — a value that evaluates to True — it returns False and vice versa.

Add the not operator at the beginning of the if condition to check if the character is not alphabetic.

But, on having the code:

if not(char.isalpha()):
final_message += char

get the error still.

Your code so far

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

            # 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)
decryption = vigenere(encryption, custom_key, -1)

Your browser information:

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 80

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.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

not is not a function
it is used like not True, not False, not <expression>

remove the parenthesis for not and add a space right after not

I have to say, and maybe I don’t have the experience, but the instructions aren’t apparent in some cases.

it’s subtle, but an operator is never used with parenthesis. Do you think it needs to be said explicitly?

Thank you for clarifying. I was talking more in general. So far, it has been a great journey. Thank you for the quick response.

If you have a problem or question please open a new topic and be specific.

Vague complaints on month old threads aren’t helpful for anyone.

This is the third time you’ve been notified about this, so fair warning :+1: