Hi there!
I am stuck at step 38. Just couldn’t figure out how to do it, how to replace a variable with a new one, one that variable was already assigned a value of ‘’??. I really wanted to skip it, but didn’t know how either. Please help.
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
new_char = alphabet[new_index]
encrypted_text = new_char
print('char:', char, 'new char:', new_char)
# 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 38
Appreciate your response. However. I did not know how to do that.
I wrote encrypted_text = new_char , but did not work. In order to change a variable, you either delete it and type the new one or assign it to a new variable, according to my very humble understanding. So which one is relevant here?
Maybe I am, but my guess I am a bit SLOW at this point.
So, should I replace the name and preserve the same value, i.e. encrypted_text = alphabet[new_index], OR encrypted_text = new_char, OR encrypted_text =“”?
You should replace the name and keep the value. Also, after that you’ll need to change the print() call because you won’t have new_char declared anymore.
Thank you so much. It was really simple; committing more than one minute mistake will get you in circles by fixing one and leaving the other interchangeably. Your advice and reassurance were much needed. Thanks.