Learn String Manipulation by Building a Cipher - Step 68

Tell us what’s happening:

i dont know what to do in this, the instructions seem pretty unclear

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
            # 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]

# User Editable Region

    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/ Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 68

This is what you did, you formed a function instead of calling a function. You only have one function in your code, it’s that function that you’re supposed to call. After calling it, you have to store it in an encryption variable.

what would be the exact code for it

I can’t give you the exact code. It’s against the forum’s rules and regulations.

what should i write after return

You first have to create an encryption variable and then assign the variable the function call with some two arguments. Let me structure a syntax here that will give you a hint on how to go about this.

This is how we call a function and some arguments.

function_name(argument 1, argument 2)

Now call your function using thing structure and assign it to the variable.

Hi @Annmademilkshake

Call your function passing text and custom_key as the arguments. ✓

Store the return value of the function call in a variable called encryption . ✗

The first line of your new code is correct, however the indentation is wrong. Currently the function call is a part of the function above.

The second part is asking you to assign a variable to the function call.

Happy coding

this is not correct python

You need two things for this step, assign a value to a variable, and call a function passing two arguments

Please show me how you would assign the value 5 to a variable called five

Please also show me how you would call a function sum with 2 and 3 as arguments

1 Like

Welcome to the forum @christune.smith2000

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Happy coding

I’m not sure if I should make a new thread but I’m having trouble with this step as well. I’ve been at it for an hour and a half and can’t figure it out. It keeps saying I have unexpected indentation or “return” is outside function.

The end of my code looks like this and it doesn’t like it:

vigenere(text, custom_key)
encryption = vigenere()
return encryption

Yes please! Open a new thread and we can help you

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

This post is not for step 68 it is for step 67.