Caesar Cipher code issue with random keys and spaces












0















def message():
answer = input('Welcome to the Caesar Cipher! What do you want to encrypt?')
key = input('Enter the key number that you want to encrypt with. (1 - 25)')
return answer, int(key)


def getMessage(answer, key):
lengthList =
leng = 0
while leng < len(answer):
lengthList.append(chr(ord(answer[leng]) + key))
leng += 1
print("By the way, random keys are spaces.")
print("".join(lengthList))


answer, key = message()
getMessage(answer, key)


This is my Caesar Cipher Encryption Only code and my problem is that sometimes when I enter a message, some letters turn into different signs that are not letters. How do I make the printed message only include keys? I also need help that if there are spaces, it also turns into a different sign. How do you also make the spaces remain spaces?










share|improve this question























  • see this question/answer: stackoverflow.com/questions/53472494/…

    – Henry Woody
    Nov 26 '18 at 1:58











  • It still doesn't meet my question of staying in the alphabet.

    – Eric Ruocheng Wu
    Nov 26 '18 at 2:05













  • Without seeing an example, I'm guessing the leaving the alphabet problem is what happens if you have, for example, the character 'Z' and key=1 then the ciphered version of this character is '[', so you'll need to handle "wrapping" around. That point is addressed in the linked question/answer

    – Henry Woody
    Nov 26 '18 at 2:07













  • Possible duplicate of Implementing the Ceaser Cipher function through input in Python

    – 0liveradam8
    Nov 26 '18 at 2:56
















0















def message():
answer = input('Welcome to the Caesar Cipher! What do you want to encrypt?')
key = input('Enter the key number that you want to encrypt with. (1 - 25)')
return answer, int(key)


def getMessage(answer, key):
lengthList =
leng = 0
while leng < len(answer):
lengthList.append(chr(ord(answer[leng]) + key))
leng += 1
print("By the way, random keys are spaces.")
print("".join(lengthList))


answer, key = message()
getMessage(answer, key)


This is my Caesar Cipher Encryption Only code and my problem is that sometimes when I enter a message, some letters turn into different signs that are not letters. How do I make the printed message only include keys? I also need help that if there are spaces, it also turns into a different sign. How do you also make the spaces remain spaces?










share|improve this question























  • see this question/answer: stackoverflow.com/questions/53472494/…

    – Henry Woody
    Nov 26 '18 at 1:58











  • It still doesn't meet my question of staying in the alphabet.

    – Eric Ruocheng Wu
    Nov 26 '18 at 2:05













  • Without seeing an example, I'm guessing the leaving the alphabet problem is what happens if you have, for example, the character 'Z' and key=1 then the ciphered version of this character is '[', so you'll need to handle "wrapping" around. That point is addressed in the linked question/answer

    – Henry Woody
    Nov 26 '18 at 2:07













  • Possible duplicate of Implementing the Ceaser Cipher function through input in Python

    – 0liveradam8
    Nov 26 '18 at 2:56














0












0








0








def message():
answer = input('Welcome to the Caesar Cipher! What do you want to encrypt?')
key = input('Enter the key number that you want to encrypt with. (1 - 25)')
return answer, int(key)


def getMessage(answer, key):
lengthList =
leng = 0
while leng < len(answer):
lengthList.append(chr(ord(answer[leng]) + key))
leng += 1
print("By the way, random keys are spaces.")
print("".join(lengthList))


answer, key = message()
getMessage(answer, key)


This is my Caesar Cipher Encryption Only code and my problem is that sometimes when I enter a message, some letters turn into different signs that are not letters. How do I make the printed message only include keys? I also need help that if there are spaces, it also turns into a different sign. How do you also make the spaces remain spaces?










share|improve this question














def message():
answer = input('Welcome to the Caesar Cipher! What do you want to encrypt?')
key = input('Enter the key number that you want to encrypt with. (1 - 25)')
return answer, int(key)


def getMessage(answer, key):
lengthList =
leng = 0
while leng < len(answer):
lengthList.append(chr(ord(answer[leng]) + key))
leng += 1
print("By the way, random keys are spaces.")
print("".join(lengthList))


answer, key = message()
getMessage(answer, key)


This is my Caesar Cipher Encryption Only code and my problem is that sometimes when I enter a message, some letters turn into different signs that are not letters. How do I make the printed message only include keys? I also need help that if there are spaces, it also turns into a different sign. How do you also make the spaces remain spaces?







python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 1:54









Eric Ruocheng WuEric Ruocheng Wu

84




84













  • see this question/answer: stackoverflow.com/questions/53472494/…

    – Henry Woody
    Nov 26 '18 at 1:58











  • It still doesn't meet my question of staying in the alphabet.

    – Eric Ruocheng Wu
    Nov 26 '18 at 2:05













  • Without seeing an example, I'm guessing the leaving the alphabet problem is what happens if you have, for example, the character 'Z' and key=1 then the ciphered version of this character is '[', so you'll need to handle "wrapping" around. That point is addressed in the linked question/answer

    – Henry Woody
    Nov 26 '18 at 2:07













  • Possible duplicate of Implementing the Ceaser Cipher function through input in Python

    – 0liveradam8
    Nov 26 '18 at 2:56



















  • see this question/answer: stackoverflow.com/questions/53472494/…

    – Henry Woody
    Nov 26 '18 at 1:58











  • It still doesn't meet my question of staying in the alphabet.

    – Eric Ruocheng Wu
    Nov 26 '18 at 2:05













  • Without seeing an example, I'm guessing the leaving the alphabet problem is what happens if you have, for example, the character 'Z' and key=1 then the ciphered version of this character is '[', so you'll need to handle "wrapping" around. That point is addressed in the linked question/answer

    – Henry Woody
    Nov 26 '18 at 2:07













  • Possible duplicate of Implementing the Ceaser Cipher function through input in Python

    – 0liveradam8
    Nov 26 '18 at 2:56

















see this question/answer: stackoverflow.com/questions/53472494/…

– Henry Woody
Nov 26 '18 at 1:58





see this question/answer: stackoverflow.com/questions/53472494/…

– Henry Woody
Nov 26 '18 at 1:58













It still doesn't meet my question of staying in the alphabet.

– Eric Ruocheng Wu
Nov 26 '18 at 2:05







It still doesn't meet my question of staying in the alphabet.

– Eric Ruocheng Wu
Nov 26 '18 at 2:05















Without seeing an example, I'm guessing the leaving the alphabet problem is what happens if you have, for example, the character 'Z' and key=1 then the ciphered version of this character is '[', so you'll need to handle "wrapping" around. That point is addressed in the linked question/answer

– Henry Woody
Nov 26 '18 at 2:07







Without seeing an example, I'm guessing the leaving the alphabet problem is what happens if you have, for example, the character 'Z' and key=1 then the ciphered version of this character is '[', so you'll need to handle "wrapping" around. That point is addressed in the linked question/answer

– Henry Woody
Nov 26 '18 at 2:07















Possible duplicate of Implementing the Ceaser Cipher function through input in Python

– 0liveradam8
Nov 26 '18 at 2:56





Possible duplicate of Implementing the Ceaser Cipher function through input in Python

– 0liveradam8
Nov 26 '18 at 2:56












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473845%2fcaesar-cipher-code-issue-with-random-keys-and-spaces%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473845%2fcaesar-cipher-code-issue-with-random-keys-and-spaces%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin