I am trying to implement rot 13 and am having troubles. My code is as
follows:
class Rot_13(webapp2.RequestHandler):
def write_form(self, user=):
self.response.out.write(rot_form % user)
def get(self):
self.write_form()
def post(self):
user = self.request.get(text)
s = self.rot_text(user)
print
The use of index() here to find the target place where the translation
is going to occur is very fragile.
Consider: we conceptually already should know where in the list we
want the target to be, since we're walking across the characters in
the list. We know that we're looking first at ls[0],
On Tue, Mar 12, 2013 at 6:57 AM, RJ Ewing ewing...@gmail.com wrote:
I am trying to implement rot 13 and am having troubles. My code is as
follows:
class Rot_13(webapp2.RequestHandler):
def write_form(self, user=):
self.response.out.write(rot_form % user)
def get(self):
self.write_form()
On 12/03/13 05:57, RJ Ewing wrote:
I am trying to implement rot 13 and am having troubles. My code is as
follows:
There are better ways to do what you are doing but assuming this is a
learning exercise rather than a serious project I'll make some comments:
def rot_text(self, s):
ls = [i
On 12/03/13 16:57, RJ Ewing wrote:
I am trying to implement rot 13 and am having troubles. My code is as
follows:
A few comments follow.
def rot_text(self, s):
ls = [i for i in s]
for i in ls:
if i.isalpha():
if i.isupper():
if i =
What can be said after this detailed lesson...Bravo!
On 12/03/2013 11:58, Steven D'Aprano wrote:
On 12/03/13 16:57, RJ Ewing wrote:
I am trying to implement rot 13 and am having troubles. My code is as
follows:
A few comments follow.
def rot_text(self, s):
ls = [i for i in s]
Thank you all for the help. I really appreciated the suggestions. Some of
the things you pointed out, I originally used, but started changing thing
when it wasn't working. I got it to work, but if you could let me know if
there is anything I should do to make this code more pythonesque that would
RJ Ewing wrote:
Thank you all for the help. I really appreciated the suggestions. Some of
the things you pointed out, I originally used, but started changing thing
when it wasn't working. I got it to work, but if you could let me know if
there is anything I should do to make this code more
On Tue, Mar 12, 2013 at 9:00 AM, RJ Ewing ewing...@gmail.com wrote:
Thank you all for the help. I really appreciated the suggestions. Some of
the things you pointed out, I originally used, but started changing thing
when it wasn't working. I got it to work, but if you could let me know if
##
## rot1: char - char
## Rotates a single character.
def rot1(char):
if char.isupper() or char.islower():
test = 'M' if char.isupper() else 'm'
if char = test:
return chr(ord(char) + 13)
else:
return chr(ord(char) -
Also note that I've deliberately left alone a bug in rot1(), to make
it easier to show a flaw in the original code that you'll want to fix.
Doh. Never mind. _I'm_ the one who introduced that regression. :( Sorry!
Here's a corrected definition for rot1():
#
def
11 matches
Mail list logo