Could someone explain how this works? I got the right answer, but I’m not understand why it’s right, im so stupid
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
encrypted_text += char
else:
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 43
Your solution works from my end. Please try one of the following steps to move forward.
Click on the “Restart Step” button and force a refresh of your page with CTRL + F5 then try to paste the code in again.
or - Try the step in incognito or private mode.
or - Disable any/all extensions that interface with the freeCodeCamp website (such as Dark Mode, Ad Blockers, or Spellcheckers), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.
or - Ensure your browser is up-to-date or try a different browser.
I strongly recommend you learn from this Python curriculum. It is newer and prepares you better by providing theory lectures, workshops, and labs to help you learn.
You are not stupid. You are trying to learn, and that’s pretty smart! Keep at it. Take it a step at a time.
Do you have a question about how the for loop works? I’m happy to help if I can, but I need you to try to explain what it is that you are not understanding.
programmers spend a lot of time trying to figure out stupid things
the only difference between an experienced programmer and a beginner is that the experienced programmer continued programming after getting blocked by “stupid” issues