Talent
1
Tell us what’s happening:
I cant get past step 49 of Scientific computing with Python(String Manioulation by building a Cipher)
Your code so far
# User Editable Region
text = 'Hello Zaira'
shift = 3
def caesar():
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
encrypted_text += char # Add space to encrypted_text
else:
index = alphabet.find(char)
new_index = (index + shift) % len(alphabet)
encrypted_text += alphabet[new_index]
print('Plain text:', text)
print('Encrypted text:', encrypted_text)
caesar()
# 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/126.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 49
The indentation for every code line should be exactly four spaces from its starting position, which is not the case in your code.
Where did you find the instructions to call the function?
Talent
3
i do not think im getting what you are saying, i justtried the four spaces and still not getting past the challenge
Talent
4
type or paste codetext = 'Hello Zaira'
shift = 3
def caesar():
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
encrypted_text += char
else:
index = alphabet.find(char)
new_index = (index + shift) % len(alphabet)
encrypted_text += alphabet[new_index]
print('Plain text:', text)
print('Encrypted text:', encrypted_text) here
Why did you change these two lines given by default with the following strings: ‘plain text:’ and ‘encrypted text:’ (both in lowercase)?
1 Like