Python Forum
Newbie: Help with code related to Caesar Cipher
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie: Help with code related to Caesar Cipher
#1
Hi All,

Sorry if this seems like a basic question. I am trying to understand part of the code for Caesar Cipher and would be grateful if you guys can give some advice.

def getKey():
key = 0 Why do we need to define key=0?
while True: Why do we need to state while true?
print('Enter the key number (1-%s)' % (MAX_KEY_SIZE))"(1-%s)' % (MAX_KEY_SIZE)" what does this mean?
key = int(input())how does 'input()' come into play in this context (As in I do not understand where input is referring to
if (key >= 1 and key <= MAX_KEY_SIZE):
return key

Sorry if these are basics, I am just having a hard time conceptualising it.

Many thanks!
Reply
#2
All of these questions are answered in a basic tutorial. Tutorials are write once, read many and so we don't have to answer the same basic questions over and over https://wiki.python.org/moin/BeginnersGuide/Programmers
Reply
#3
(Apr-15-2018, 11:51 AM)jessiblah Wrote: key = 0 Why do we need to define key=0?
You don't. You redefine it inside the while loop, and don't use it before then, so this line is extraneous (whoever wrote the code is probably proficient in a language where you need to define your variables, such as c or java).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cesar Cipher ForsakenDusk 5 484 Apr-07-2024, 04:30 PM
Last Post: Pedroski55
Question Rsa Cipher Paragoon2 3 653 Nov-27-2023, 12:30 PM
Last Post: snippsat
  RSA Cipher with blocks Paragoon2 0 497 Nov-26-2023, 04:35 PM
Last Post: Paragoon2
  newbie question - can't make code work tronic72 2 698 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Newbie - code solution explained Stjude1982 2 1,851 Sep-16-2021, 08:54 AM
Last Post: Stjude1982
  Caesar Cipher Help pbrowne 2 2,189 Jun-30-2021, 02:36 PM
Last Post: deanhystad
  Although this is a talib related Q it's mostly related to python module installing.. Evalias123 4 5,704 Jan-10-2021, 11:39 PM
Last Post: Evalias123
  Learning Python with a Caesar cipher Drone4four 5 4,837 Nov-21-2020, 07:21 PM
Last Post: bowlofred
  newbie need help update code Mariaa 3 2,092 Oct-02-2020, 08:12 AM
Last Post: ibreeden
  The code to decrypt Caeser Cipher. lazerwolf101 2 3,157 May-26-2020, 04:01 PM
Last Post: DT2000

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020