Skip to content

Video 85 - Caesar Cipher Part 3 issue #15

@liamoc89

Description

@liamoc89

When using the code provided in this video and even in your video itself, when you decode the text at the end (around 7:48 in the video) - the decoded text comes out as holvo.

I used print(shift_amount) within the for loop to check why this happened, and it showed this in the console:
_Type 'encode' to encrypt, type 'decode' to decrypt:
decode
Type your message:
mjqqt
Type the shift number:
5
-5
5
-5
5
-5
The decoded text is holvo

It seems as though the if statement needs to be outside of the for loop:
if cipher_direction == `"decode":
shift_amount *= -1
for letter in start_text:
position = alphabet.index(letter)
new_position = position + shift_amount
end_text += alphabet[new_position]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions