Skip to content

Instantly share code, notes, and snippets.

@Toastdude
Created September 26, 2011 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Toastdude/6307144ff402dfbd0d7f to your computer and use it in GitHub Desktop.
Save Toastdude/6307144ff402dfbd0d7f to your computer and use it in GitHub Desktop.
# Code is based off of forum post from user "vegaseat" on http://www.daniweb.com/software-development/python/threads/63552
def choice():
print '1) Encrypt Text';
print '2) Decrypt Text';
print '3) Exit';
choose = input("Enter Choice: ");
if choose == 1:
En();
elif choose == 2:
De();
elif choose == 3:
print 'Bye!';
else:
print 'Enter valid choice.';
print;
choice();
def En():
str1 = raw_input("Enter text to be encoded: ");
encodedstr1 = str1.encode('rot13');
encodedstr2 = list(encodedstr1)
encodedstr2.reverse()
encodedstr2[0:] = [''.join(encodedstr2[0:])]
print "Encoded text: ", encodedstr2;
print;
raw_input("Press <Enter>");
print;
choice();
def De():
str1 = raw_input("Enter text to be decoded: ");
decodedstr1 = str1.encode('rot13');
decodedstr2 = list(decodedstr1);
decodedstr2.reverse();
decodedstr2[0:] = [''.join(decodedstr2[0:])];
print "Decoded text: ", decodedstr2;
print;
raw_input("Press <Enter>");
print;
choice();
@Steve-V
Copy link

Steve-V commented Dec 7, 2011

On line 27 and 41, you don't actually need to use [0:], you can do [:] and it will still work - the 0 is assumed, if you don't put anything in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment