Learn String Manipulation by Building a Cipher - Step 41

Tell us what’s happening:

Says code does not pass. what am I missing here? Tried changing space after if statement colon and checked indentation but still code does not pass.

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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 41

You have a spacing issue in your code.
After the equality operator, allow your code a single bar space. If char is a space, your condition should evaluate to true, therefore the quotation marks should have some space inside. That way, the conditions will be checking if the char is an empty space.

Such a prompt response. Got it. Just needed a space between ‘’ in the if statement. As a beginner I’m starting to enjoy coding. Thanks to u amazing guys. :+1:

You are very welcome Karthick, keep doing the good work.