I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .
I'd say the code is not bad, just a few style issues and a couple of practical things.
- You don't need two lines to lowercase the input string, you can do directly
inp = input('Input the text you want to code:\n').lower()
You're not checking user input, if the second input is not an integer,
int()
will generate aValueError
. You should put atry/catch
around that.Your input implies that numbers lower than
1
and higher than25
are not acceptable, while actually you're accepting them and doing something different than what you told the user. Either you generate an error and refuse the input, or you say that the input will be modified accordingly. Either way the user should know what's going on.You have quite a few hard-coded values, consider using constants .
The comment
# If the final number is greater than 122..
is useless, the code is clear at that point.The comment
# Function to code a text with caeser chyper.
should actually be a docstring . You should also specify what you expect as input and what kind of output you return.I would rename the variable
input
toinput_string
, just so it's not the same name of theinput()
function.elif((num + key <= 122)):
is actually justelse:
You're printing inside of the function. I'd return the value and let the caller decide what to do with it.
You may want to consider putting
if __name__ == "__main__":
in your code and call your function from there.This is a simple function, so no need to dig too deep but if you want, you may have a look here about string concatenation .