Hey guys! Check out my ROT13 Decoder in Python!:
Alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
Alphabet2 = list('abcdefghijklmnopqrstuvwxyz')
while True:
Result = ""
Text = raw_input('Enter text here to translate to ROT13:')
if Text.lower() == '/quit':
break
for i in range(0, len(Text)):
if Text[i] in Alphabet:
if Alphabet.index(Text[i]) <= 12:
Result = Result + Alphabet[Alphabet.index(Text[i]) + 13]
else:
Result = Result + Alphabet[Alphabet.index(Text[i]) - 13]
elif Text[i] in Alphabet2:
if Alphabet2.index(Text[i]) <= 12:
Result = Result + Alphabet2[Alphabet2.index(Text[i]) + 13]
else:
Result = Result + Alphabet2[Alphabet2.index(Text[i]) - 13]
else:
Result = Result + Text[i]
print ('The translation is: ' + Result)EDIT: I added a while loop so that you can type in as many things as you like.
EDIT: Added a /quit command.
EDIT: /quit is no longer case sensitive.
Last edited by ImagineIt (2012-05-27 20:34:38)
Offline
I'm no good at python, but from skimming docs, you can try STRING_TEXT_WHATEVER_VARIABLE.ascii_uppercase.
Offline
Your method is not seeming to work for me bobbybee. I can show the code to you if you would like:
Alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
Result = ""
Text = raw_input('Enter text here to translate to ROT13:')
for i in range(0, len(Text)):
if Text[i] in Alphabet:
if Alphabet.index(Text[i]) <= 12:
Result = Result + Alphabet[Alphabet.index(Text[i]) + 13]
else:
Result = Result + Alphabet[Alphabet.index(Text[i]) - 13]
else:
Result = Result + Text[i]
print(Result)Offline
I dunno, but maybe:
Alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
Result = ""
Text = raw_input('Enter text here to translate to ROT13:')
Text = Text.ascii_uppercase
for i in range(0, len(Text)):
if Text[i] in Alphabet:
if Alphabet.index(Text[i]) <= 12:
Result = Result + Alphabet[Alphabet.index(Text[i]) + 13]
else:
Result = Result + Alphabet[Alphabet.index(Text[i]) - 13]
else:
Result = Result + Text[i]
print(Result)Offline
It's .upper() I believe
print 'lowercase is uppercase'.upper()
Offline
Nope...
Wait, didn't you code all of DragonThunder in Python? Or was that Flash?
Offline
Well, Magnie made the mirror in Python, and I did some extra stuff for FireMMO compatibility (but Magnie get's most the credit)
Offline
Thank you so much Magnie! And thank you for your attempt to help me bobbybee, I appreciate your effort.
Offline
ImagineIt wrote:
Thank you so much Magnie! And thank you for your attempt to help me bobbybee, I appreciate your effort.
As I said, I'm not much of a Pythoner.
Offline
I edited the code to work nicer.
Last edited by ImagineIt (2012-05-26 22:23:01)
Offline
Offline
Wait, wait, wait... this sounds a LOT like CF4, which is made by me. CF4 uses more If's, though...
Offline
GeonoTRON2000 wrote:
Wait, wait, wait... this sounds a LOT like CF4, which is made by me. CF4 uses more If's, though...
I thought of using that language once, but it's to easy to discover.
Offline