Ask coding questions

← Back to all posts
How do I reverse my Cipher

I have found a caesor cipher but i am unsure how to make it decrypt my messages.

Answered by heyitsmarcus (325) [earned 5 cycles]
View Answer
JustARatherRidi (209)

You've got the right idea, but there are a couple of problems in your code.

  • You've left the plaintext variable empty, but you're trying to iterate over it in your first loop. So the encryption part doesn't really do anything.
  • In lines 11 and 17, you say L2I[c] + key and L2I[c] - key. L2I[c] gives you an int in both cases, but key is a str. You can't add an integer to a string, so python throws an error.

What exactly do you want key to do?

heyitsmarcus (325)

@JustARatherRidi And don't forget the random = line that is breaking the script immediately!


Thanks! I see what to do now.

JustARatherRidi (209)

@FreddyChelsom If he helped you out, you should mark his comment as the answer.

heyitsmarcus (325)

@JustARatherRidi I surely did not expect that. But, I definitely gave you an upvote Ridi. Always helpful info, bud!

JustARatherRidi (209)

@heyitsmarcus Its all cool, I think I deserved it for missing that one. As you said, we're all just trying to help people out :)