Learn String Manipulation by Building a Cipher - Step 40

Tell us what’s happening:

Hi I have tried the following steps and it is still not working on Step 40 please assist me. Thanks Cameronfor char in text.lower():
char = ‘’
print (char == ‘’)
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
    
for char in text.lower():
    char = ''
    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

Your browser information:

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 40

Hi my Code is not passing through is it wrong how I did it or is there a problem please assist. Thanks.

'' empty string
' ' space

Hi I tried that and it is still not working

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

This is my code so far for Step 40 I am not sure why it is not working.

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

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 (').

'' empty string
' ' space
'  ' 2 spaces

Hi I am using the back ticks

Hi I have put 2 spaces and it is still not working

Ok, how many spaces do the instructions ask for?

Hi this is the Output I am not sure if this is correct please check and let me know. Thanks.
False
char: h encrypted text: k
False
char: e encrypted text: kh
False
char: l encrypted text: kho
False
char: l encrypted text: khoo
False
char: o encrypted text: khoor
False
char: encrypted text: khoorc
False
char: w encrypted text: khoorcz
False
char: o encrypted text: khoorczr
False
char: r encrypted text: khoorczru
False
char: l encrypted text: khoorczruo
False
char: d encrypted text: khoorczruog

if it doesn’t pass the test, then it’s not correct

It just says space it does not indicate how many spaces.

Hi this is the instruction as follow below:
At the beginning of your loop body, print the result of comparing char with a space (' ' ). Use the equality operator == for that.

result of comparing char with a space (' ')

It says “a space” which means one space. It also gives the example there with 1 space in quotes. You could copy/paste that.

“a space” means 1 space

Hi I have tried putting 1 space as well it still giving an error

Try to reset the step, and read the instructions again now that we’ve sorted out the space.

If it doesn’t work, read the error message or hint and try to solve it again based on that information.

Then share your updated code here.

Please reply and copy/paste your code into this thread