Learn String Manipulation by Building a Cipher - Step 42

Conte-nos o que está acontecendo:

Descreva detalhadamente o problema aqui.

Seu código até o momento

# User Editable Region

text = 'Hello Zaira'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
    if char == ' ':
        encrypted_text += char
        index = alphabet.find(char)
        new_index = index + shift
        encrypted_text += alphabet[new_index]
        print('char:', char, 'encrypted text:', encrypted_text)
alphabet(index + shift)

# User Editable Region

Informações do seu navegador:

Agente de usuário: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Informações do desafio:

Learn String Manipulation by Building a Cipher - Step 42

Surround index + shift with parentheses, and modulo the expression with 26, which is the alphabet length.
what exactly is there to do in this part?

here: 3 + 5 x 3 is 18 right? And when you add parentheses to it, like this: (3 + 5) x 3 is now 24. And back to the problem, just think index is 3 and shift is 5 in the case I mention eariler, and when they modulo in python it is this: % so just put all the together with 26!

1 Like

Im still confused so where do you put it and do you put 26%?

The percent sign ( modulo) goes in front of the 26 in your expression, like this %26. Read over the instructions again out loud and study tytywentoutformilks usage of parentheses (the above comment) from the result of 24 and apply it to index+shift.