[Tutor] Rot13
Nidian Job-Smith
nidianjs at hotmail.com
Thu Nov 17 18:54:54 CET 2011
Sorry about the code format in last E-mail. I'll attach the code in notepad, as my e-mail doesnt seem to like sending plain text..
----------------------------------------
> From: nidianjs at hotmail.com
> To: steve at pearwood.info; tutor at python.org
> Date: Thu, 17 Nov 2011 17:45:11 +0000
> Subject: [Tutor] Rot13
>
>
> Hi all,
>
> I'm new to programming (thus Python), so after reading the basics, I wanted to practise what I've learnt .
> I've come across a beginners exercise which is to write the code for rot13. I've written some code but it doesn't seem to work....
> When I run it I get this error:
>
>
> NameError: global name 'rot13_char' is not defined
>
>
> Here it is:
>
>
>
> def rot13(s): char_low = () result = "" if not s.isalpha(): return char char_low = char_low.lower() if char_low <= 'm': dist = 13 else: dist = -13 char = chr(ord(char) + dist) def rot13(string): return ''.join( rot13_char(char)for char in string )
>
>
>
>
> Any ideas where i'm wrong?
>
> Huge thanks,
> Nidian
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rot13_code.txt
URL: <http://mail.python.org/pipermail/tutor/attachments/20111117/3fb8c0a4/attachment.txt>
More information about the Tutor
mailing list