Learn String Manipulation by Building a Cipher - Step 83

Tell us what’s happening:

Describe your issue in detail here.

Hi team. When I write the code the way I wrote it, the output is correct. But when I do:
encryption = encrypt(text, custom_key)
print("Encrypted text: " + text)

I have an error.

Your code so far

``````text = 'mrttaqrhknsw ih puggrur'
custom_key = 'python'

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

for char in message.lower():

# Append any non-letter character to the message
if not char.isalpha():
final_message += char
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

def encrypt(message, key):
return vigenere(message, key)

def decrypt(message, key):
return vigenere(message, key, -1)

/* User Editable Region */

encryption = encrypt(text, custom_key)
print('Encrypted text:'+' ')
decryption = decrypt(encryption, custom_key)
print(decryption)

/* User Editable Region */

``````

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 83
https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-83`Preformatted text`

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.

here the code in the `print` statement is missing something

what error do you get in this case?

Here is the updated code. I sitll can’t pass this step.

``````encryption = encrypt(text, custom_key)
print('Encrypted text:'+'text')
decryption = decrypt(encryption, custom_key)
print(decryption)
``````

Hello Brice,
`text` is a variable, but instead you wrote `'text'` which is literally just a string that says text. If you want the string inside text you have to call the variable.

(Also slight note, you forgot a space at the end of the first string.)

I wrote it this way, but it is still not correct.

``````encryption = encrypt(text, custom_key)
print('Encrypted text:' + text)
decryption = decrypt(encryption, custom_key)
print(decryption)
``````

You’re missing the space after the `:` character in the string. In the console you can see it now says `Encrypted text:mrttaqrhknsw ih puggrur` all next to each other without a space.

I added the space as you mentioned. it is still the same.

``````encryption = encrypt(text, custom_key)
print('Encrypted text: '  + text)
decryption = decrypt(encryption, custom_key)
print(decryption)`````````

That should be correct, (assuming you didn’t write the ``` part ofc). And passes for me, are you sure you didn’t accidently edit anything else? You can try and use the reset button to start fresh and update it again.

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