Aprenda la Manipulación de Cadenas Construyendo un Cipher - Step 40

Cuéntanos qué está pasando:

text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
encrypted_text = ‘’

for char in text.lower:
print(char==‘’)

index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index] 
print('char:', char, 'encrypted text:', encrypted_text)

this is my code I’m kind stuck on this step, please help my people ??

Tu código hasta el momento


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower:
   print(char=='')
  
   
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += alphabet[new_index] 
    print('char:', char, 'encrypted text:', encrypted_text)

# User Editable Region

Información de tu navegador:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Información del Desafío:

Aprenda la Manipulación de Cadenas Construyendo un Cipher - Step 40

Welcome to the forum @gaspp

Here is a comparison of the original code and your code.

The code in blue is the original code, the code in red is your code.
The code in magenta is the overlap.

image

  1. Looks like you removed the round braces from the for loop
  2. The print call needs one space of indentation
  3. Read the instructions carefully on what char is compared to

Happy coding

Hey my friend I just correct the error of the round braces and also as long as I could understand CHAR is to compare with space ’ ’ , but can’t go any further, any other suggestion here my code again:

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
 
  print (char == '')     
    
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += alphabet[new_index] 
    print('char:', char, 'encrypted text:', encrypted_text)

thanks in advance

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Please note:

'' #empty string
' ' #space character

Keep your indentations consistent.