You should indent the lines of code after your “else” clause.
What is the error?
Can someone explain?
/* User Editable Region */
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
encrypted_text += char
else:
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 */
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 40
Learn to Code — For Free
system
December 27, 2023, 8:25am
2
You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.
Hello @inocencio80
Indentation is important in Python language. see here and also here .
Good luck!
1 Like
you should indent all the lines below the else clause as they belong inside it…
Say,
else:
print()
indent all the 4 lines
1 Like
Let me describe how to carry out indentation in python for you.
You can use either spaces or tabs for indentation, but be consistent with one.
PEP 8 (Python Enhancement Proposal 8), recommend using 4 spaces for each level of indentation. Try this let see how it goes.
1 Like
ILM
December 27, 2023, 9:07am
6
you indented only the first line, indent all the lines after the else statement
1 Like
system
Closed
June 27, 2024, 5:31pm
8
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.