Newbie: Help with code related to Caesar Cipher - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Newbie: Help with code related to Caesar Cipher (/thread-9539.html) |
Newbie: Help with code related to Caesar Cipher - jessiblah - Apr-15-2018 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! RE: Newbie: Help with code related to Caesar Cipher - woooee - Apr-15-2018 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 RE: Newbie: Help with code related to Caesar Cipher - nilamo - May-15-2018 (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). |