Learn String Manipulation by Building a Cipher - Step 42

Tell us what’s happening:

this is very confusing since don’t know what else to try i have looked at almost every topic for step 42 and its really bugging me.
i tried leaving more spaces, replacing space with char
it still dosn’t work

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
    if char == ' '
        print(space!)
    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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 42

You missed the colon : after your condition. It’s necessary to indicate the start of an indented block of code after your condition.

Also, you need to enclose the string you want to print between double quotes "" or single quotes ''. This is mandatory for any string.

print("Hello, World!")

Tell us what’s happening:

i do not know where the indentation error is please help me i have been stuck for days i have tried everything

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
    if char == ' ': 
    print('space!'):
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += alphabet[new_index]
    print('char:', char, 'encrypted text:', encrypted_text)
    pass

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 42

Hi @setayesh0723

Please indent the print statement by four spaces, and remove the colon at the end of this line.

Happy coding

thank you i was stuck for days

1 Like