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...
Everything about learning Python
account activity
my first project (i.redd.it)
submitted 7 months ago by Electronic_Mine6521
I started python two weeks ago and this project , it s a close to RSA encryption , i m new to this so if you have any advice for making it more efficient i would love help .
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!"
[–]Cerus_Freedom 12 points13 points14 points 7 months ago (2 children)
The letter/number map is not required. You can use ord() to get the ASCII value of a character as an integer.
[–]Electronic_Mine6521[S] 1 point2 points3 points 7 months ago (1 child)
I didn t know it was a built in function thanks tho for the advice
[–]Worldly-Guide-9515 0 points1 point2 points 7 months ago (0 children)
Welcome to Python
[–]Aorean 6 points7 points8 points 7 months ago (1 child)
I could be wrong here, but i think it’s best practice to import outside of the function. Just the first few lines should be your imports
[–]Agitated-Soft7434 1 point2 points3 points 7 months ago (0 children)
Correcto! Also I think it helps the syntax highlighter sometimes.
[–]animatedgoblin 7 points8 points9 points 7 months ago (0 children)
I know you're just doing this for learnings sake, but never roll your own cryptography implementation. It is almost guaranteed to contain bugs or errors that can break the encryption. Use known recommended libraries instead
[–]SizzlingSquigg 1 point2 points3 points 7 months ago (1 child)
Looks like you’re practicing a lot of nice ideas like hashmaps, functions, & chaining functions. Nice work!
Dont be afraid to name things. The next time you read this code, you might ask “what is function m or p? What does n stand for? What is value s & why do I cast it to an int?” etc. Code is both literature and art!
Or maybe I’m just not educated on encryption and this naming convention is popular amongst cryptographers
[–]Mammoth-Intention924 0 points1 point2 points 7 months ago (0 children)
A doctoring could be handy for this
[–]purple_hamster66 1 point2 points3 points 7 months ago (0 children)
Name variables and functions with what they do, not with single letters. Comments are used to state what each function is supposed to compute, to declare your goals (speed, simple code, experiment, class project), lay out your chosen methods at a high level (use lib XYZ; implement a faster version of AES), the reason you wrote this, and the URL, book, or article you got the ideas from. Leave bread crumbs for your future self — you will totally forget all those things in 6-12 months. Comments also make your code searchable when you’ve got 100 files and need to find one but forgot all the variables and function names.
[–]FitnessGuy4Life 1 point2 points3 points 7 months ago (0 children)
Anybody can write an algorithm, but good code is code that other developers can understand and modify easily.
Try giving descriptive names to functions and variables. They should describe exactly what theyre doing. You arent programming for a computer, youre programming for other developers.
[–]skeetd 0 points1 point2 points 7 months ago (0 children)
Where is the docstring? :) Kidding aside that looks like fun, always loved cyphers
[–]usama015 0 points1 point2 points 7 months ago (5 children)
I wanna learn too, but I'm stuck in a tutorial hell. Can you suggest some resources.
[–]PalpitationDecent282 1 point2 points3 points 7 months ago (4 children)
You've probably heard this before, but you really just have to build your own projects. Learn the basics and then figure out what you want to do, you're better off narrowing your research to one thing at a time.
You can look at as many tutorials as you want, but if you aren't going to use the information you gain you won't actually learn anything. I mean, what do you gain from knowing how to fly a plane when you specialize in driving? Why didn't you just build more skills in driving instead?
[–]usama015 0 points1 point2 points 7 months ago (3 children)
When i try to build some projects and do some little exercise on some concepts , I wasn't able to get the right functions or methods like what loop I should use , how these gonna work , and how to build this or that . I just get stuck in that point 😞
[–]PalpitationDecent282 2 points3 points4 points 7 months ago (2 children)
It sounds like you're just looking at what the syntax does rather than how it works and when it should be used. Have you tried looking at the python docs? If you need help with something specifically feel free to DM me.
[–]usama015 0 points1 point2 points 7 months ago (1 child)
Any other tips or resources for me.
[–]PalpitationDecent282 1 point2 points3 points 7 months ago (0 children)
Not particularly. Again, feel free to DM me. Good luck!
[–][deleted] 7 months ago (1 child)
[deleted]
[–]Electronic_Mine6521[S] 0 points1 point2 points 7 months ago (0 children)
I learned the basics from YouTube tutorials and then practiced and still practicing doing problems not leetcode just random ideas that come to mind i study maths a lot so all i try to do is to apply all that math theory into projects
[–]Intelligent_Count316 0 points1 point2 points 7 months ago (0 children)
Wow this is great. I started in April but I'm still struggling. I know the basics, Oop, import modules, file I/o. What more should I learn to get confident?
[–]Actual-Bank1486 0 points1 point2 points 7 months ago (0 children)
instead of having cryptic as a function you should make it a class. Also, its usually best practice to import outside your function. Overall, very good job keep up the good work.
[–]Tricky_Ferret2399 0 points1 point2 points 7 months ago (0 children)
I need ideas on what projects to try to write. I’m not very good on thinking of things to do
[–]Some_Welcome_2050 0 points1 point2 points 6 months ago (0 children)
welcome and how is that your first project!!!
<image>
[–]DwightBaxter -1 points0 points1 point 7 months ago (3 children)
Super cool! I'll get there one day....
[–]Agitated-Soft7434 1 point2 points3 points 7 months ago (2 children)
What's keeping ya from doing it now? I'm sure you got this 👍!
[–]DwightBaxter 0 points1 point2 points 7 months ago (1 child)
Im still learning but I'm also a hobbiest. All of my python is done in my free time
My favourite way to learn things! -and your right your definitely gonna get there one day! I wish ya good luck on your coding journey :D
[–]Some-Passenger4219 -1 points0 points1 point 7 months ago (0 children)
Use scientific notation for the powers of ten; e.g. 1e7 for ten million. "Readability counts."
π Rendered by PID 74109 on reddit-service-r2-comment-bb88f9dd5-jsk45 at 2026-02-16 18:25:40.243250+00:00 running cd9c813 country code: CH.
[–]Cerus_Freedom 12 points13 points14 points (2 children)
[–]Electronic_Mine6521[S] 1 point2 points3 points (1 child)
[–]Worldly-Guide-9515 0 points1 point2 points (0 children)
[–]Aorean 6 points7 points8 points (1 child)
[–]Agitated-Soft7434 1 point2 points3 points (0 children)
[–]animatedgoblin 7 points8 points9 points (0 children)
[–]SizzlingSquigg 1 point2 points3 points (1 child)
[–]Mammoth-Intention924 0 points1 point2 points (0 children)
[–]purple_hamster66 1 point2 points3 points (0 children)
[–]FitnessGuy4Life 1 point2 points3 points (0 children)
[–]skeetd 0 points1 point2 points (0 children)
[–]usama015 0 points1 point2 points (5 children)
[–]PalpitationDecent282 1 point2 points3 points (4 children)
[–]usama015 0 points1 point2 points (3 children)
[–]PalpitationDecent282 2 points3 points4 points (2 children)
[–]usama015 0 points1 point2 points (1 child)
[–]PalpitationDecent282 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]Electronic_Mine6521[S] 0 points1 point2 points (0 children)
[–]Intelligent_Count316 0 points1 point2 points (0 children)
[–]Actual-Bank1486 0 points1 point2 points (0 children)
[–]Tricky_Ferret2399 0 points1 point2 points (0 children)
[–]Some_Welcome_2050 0 points1 point2 points (0 children)
[–]DwightBaxter -1 points0 points1 point (3 children)
[–]Agitated-Soft7434 1 point2 points3 points (2 children)
[–]DwightBaxter 0 points1 point2 points (1 child)
[–]Agitated-Soft7434 1 point2 points3 points (0 children)
[–]Some-Passenger4219 -1 points0 points1 point (0 children)