Learn String Manipulation by Building a Cipher - Step 40

Tell us what’s happening:

I am stuck at step 40 pls help
What is wrong in my code???

Your code so far


# 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

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 40

if you need to test if char is equal to space, you are missing something in the string you are testing it against

I tried but it’s not working

what have you tried?

I tried printing by comparing char ==’ ’ in my code

1 Like

isn’t that the same code you have shared earlier? as I said you are missing something there. A space is a character, if you need to compare against a space it needs to be there

2 Likes

Thanks sir it’s work

1 Like

if you need help with a challenge you can open your own topic using the HELP button

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 Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The 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.

you must open your own topic