I did a few trials and I lost it pls explain it to me in the simplest fourm. thanks!
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if True
if (char)'space!' 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
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 41
Hello, if statements evaluate to true if the condition they are examining is True, if it is not they evaluate to False
Consider this example, write an if statement that evaluates to True if the age variable is greater than 18 and prints adult, if it evaluates to False , it will not do anything
age = 20
if age > 18 :
print('adult')
This is very similar to your situation except you are checking if the variable char is empty space and printing space if it is
Hope this helps and if you are still confused check this out
Here is a comparison of the original code and your code.
The code in blue is the original code, the code in red is your code.
The code in magenta is the overlap.
You should replace print(char == ' ') with an if statement that triggers when char == ' ' . Do not use parentheses to enclose the if condition and remember to include the final colon.
remove the if True condition
use the hint message to structure the if condition. Do not use round braces. Remove False