Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In Caesar cipher, each letter is replaced by another letter which occurs at the d-th position (when counted from the position of the original letter), in the English alphabet. For identifying the position of a letter, we follow the usual order of the English alphabet, from a to z. Given a word and a positive integer d, use Caesar cipher to encrypt it. For example, if the word is 'ball' and the value of 'd' is 3 then the new encrypted word is 'edoo'. 'x' will be replaced by 'a', 'y' should be replaced by 'b' and 'z' should be replaced by 'c'. While the code is submitted for Online Judge (SkillRack), use rstrip(), to remove carriage return character in the input.

Input Format


A positive integer 'd'

Output format:

Encrypted word

What I have tried:

for i in range(0,len(y)):
Updated 12-Dec-20 6:15am

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
Share this answer
you could start by using meaningful names for your variables. Using single letters does not make your code more efficient, in fact quite the opposite, because it is more difficult t understand. So, following the instructions:
word = input("Enter the source word: ")
offset = int(input("Enter the offset value: "))
answer = []

Now you can think about how you process each letter in the string. Remember to calculate the new value when the addition of the offset goes beyond the letter z (or Z). It is probably easiest to stick to all lower case or all upper case to start with.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900