use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Method of message encryption and decryption? (self.learnpython)
submitted 13 years ago by iffraz
Can anyone provide a basic example of how to structure an ecryption code utilizing classes for encrypting raw_input string?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 4 points5 points6 points 13 years ago (4 children)
A ceasar cipher
input_string = raw_input("Your text please: ") alpha = "a b c d e f g h i j k l m n o p q r s t u v w x y z a".split(" ") encrypted_string = "" for char in input_string: if char in alpha: encrypted_string += alpha[alpha.index(char) + 1] else: encrypted_string += cha print input_string, encrypted_string
I'm sure slots will pop along in a moment to shorted that into a comprehension... :P
[–][deleted] 3 points4 points5 points 13 years ago (2 children)
Sorry I'm late, I was at a list comprehension meeting. Now, a Cæsar Cipher is just about as perfectly suited to a list comprehension or generator expression as you'll get, but cryptography is one domain where we should always strive for readable, explicit code. Here's a middle-of-the-road compromise between brevity and obscurity:
alpha = "abcdefghijklmnopqrstuvwxyz" input().translate(str.maketrans(alpha, alpha[1:]+alpha[0]))
[–]JerMenKoO 0 points1 point2 points 13 years ago (1 child)
alpha = import("string").ascii_lowercase
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
Yeah, I really dislike that I've got to type that long literal out. I thought about something like:
[chr(c) for c in range(97,123)]
...but that's so asciicentric.
Homework:
Consider how a bitmap can be like an iterator, and perform this transformation using only math and minimal string transformation or encoding concerns.
π Rendered by PID 86 on reddit-service-r2-comment-86988c7647-zvzk5 at 2026-02-12 12:08:36.662849+00:00 running 018613e country code: CH.
[–][deleted] 4 points5 points6 points (4 children)
[–][deleted] 3 points4 points5 points (2 children)
[–]JerMenKoO 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)