Learn String Manipulation by Building a Cipher Step 40

Tell us what’s happening:

I don’t know why I am not passing this step, I have created an else clause yet it still tells me to create an else clause.

Your code so far

/* User Editable Region */

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

for char in text.lower():
    if char == ' ':
        encrypted_text += char
            print("encrypted: ",encrypted_text)
            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/ Safari/537.36 Edg/

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 40

Hi there and welcome to our community!

The else clause (and its code block) should be indented to the same level as the if clause above it.

Unindent everything from the else line (incl.) onwards back four spaces.

1 Like

As @igorgetmeabrain explained, indentation.

You can see some examples of how to format if/else here:

if b > a:
  print("b is greater than a")
  print("b is not greater than a")
1 Like

thank you @igorgetmeabrain and @pkdvalis I managed to figure it out not too long after making this post, now I’m sure to remember it :grinning:

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