Learn String Manipulation by Building a Cipher - Step 38

Tell us what’s happening: I’m not sure what it wants me to do.

i’m not sure for to do everything in one if statement and I don’t know if its ok for me to use two and i dont know whats wrong with my ‘print (space!)’ line.

Your code so far

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

for char in text.lower():
    if char == ' ':
        char == True
        if char != ' ':
            char == False
        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

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

for char in text.lower():
    if char == ' ':
        char == True
        if char != ' ':
            char == False
    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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 38

What are you trying to do with the if statements? This logic does not seem to implement the instructions:

replace new_char with encrypted_text. Also, modify the print() call into print('char:', char, 'encrypted text:', encrypted_text)

Does not mention anything about these if statements, you can delete them.

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