You need to carefully read your conditions:
Given a space, it ord(letter) + shift
will store 32 + shift
in shifted
(35 when shift
equal to 3). This is <65, so 26 is added, in this case it leads to 61, and the character with the number 61 appears =
.
, , string.ascii_letters
, , :
import string
...
for letter in text:
if letter not in string.ascii_letters:
cipher += letter
continue
...