Learn String Manipulation by Building a Cipher - Step 67

Tell us what’s happening:

I don’t whether It is the indentation that I’m getting it wrong or the main code because I can’t find solution to Learn String Manipulation by Building a Cipher 67 particularly

Your code so far

text = 'Hello Zaira'
custom_key = 'python'

def vigenere(message, key):
    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


# User Editable Region

    vigenere(text,custom_key)
    encryption = encrypted_text

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.6099.119 Mobile/15E148 Safari/604.1

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 67

Indentation is definitely an issue. You don’t want to call the function inside the function here.

The encrypted_text variable only exists in the function so this will not work outside the function.

To store the return value of a function in a variable looks like this:

variable = function()