Learn String Manipulation by Building a Cipher - Step 66

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

i have looked at other post but i am not able to figure this one out would love some help <3

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

# User Editable Region

            # Define the offset and the encrypted letter
            offset = alphabet.index(key_char)
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
        return (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/122.0.0.0 Safari/537.36 Edg/122.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 66

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!

Hello!

“return” is a special statement, followed by an optional value - in this case encrypted_text - the value doesn’t need to be wrapped in brackets.


this hasnt solved the problem

The return keyword must be aligned with the for loop keyword. It is not easy to see but it doesn’t look like that’s the case.

1 Like

yeah thanks i needed to take remove 8 spaces / 2 indentations

1 Like

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