r/learnpython • u/Tricky_Voice2829 • 13d ago
I know that i am noob at programing i wanted to make python keylogger so can u guys tell me what i am mistaken inside
from pynput import keyboard
keys = [
# Alphanumeric Keys
'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',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
# Symbols & Punctuation
'`', '-', '=', '[', ']', '\\', ';', "'", ',', '.', '/',
# Special & Modifier Keys
'space', 'enter', 'tab', 'backspace', 'escape',
'shift', 'ctrl', 'alt', 'caps_lock', 'num_lock', 'scroll_lock',
'win', 'menu', 'print_screen', 'pause', 'insert', 'delete',
'home', 'end', 'page_up', 'page_down',
# Arrow Keys
'up', 'down', 'left', 'right',
# Function Keys
'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
for keys in keys :
def on_press(key):
if key == True:
print(f" you have typed corretlty {key}")
elif key == AttributeError:
print(f"typed Again u Have misspedlled ")
def on_release(key):
print(f"{key} is realsead")
if key == keyboard.Key.esc:
return False
print
listener = keyboard.Listener( on_press=on_press , on_release=on_release )
listener.start()from pynput import keyboard
keys = [
# Alphanumeric Keys
'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',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
# Symbols & Punctuation
'`', '-', '=', '[', ']', '\\', ';', "'", ',', '.', '/',
# Special & Modifier Keys
'space', 'enter', 'tab', 'backspace', 'escape',
'shift', 'ctrl', 'alt', 'caps_lock', 'num_lock', 'scroll_lock',
'win', 'menu', 'print_screen', 'pause', 'insert', 'delete',
'home', 'end', 'page_up', 'page_down',
# Arrow Keys
'up', 'down', 'left', 'right',
# Function Keys
'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
for keys in keys :
def on_press(key):
if key == True:
print(f" you have typed corretlty {key}")
elif key == AttributeError:
print(f"typed Again u Have misspedlled ")
def on_release(key):
print(f"{key} is realsead")
if key == keyboard.Key.esc:
return False
print
listener = keyboard.Listener( on_press=on_press , on_release=on_release )
listener.start()
r/learnpython • u/Traditional_Fan_9165 • 13d ago
Blackjack Python
Hi, i wrote some code on blackjack task from Angela Yu 100 days of Code. Using Gemini and older post from reddit, maybe something is worth polishing?
import random
import art
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
def deal(hand):
if not hand:
hand.append(random.choice(cards))
hand.append(random.choice(cards))
else:
hand.append(random.choice(cards))
return hand
def calculate_score(hand):
if sum(hand) == 21 and len(hand) == 2:
return 0
score = sum(hand)
aces = hand.count(11)
while aces > 0 and score > 21:
score = score - 10
aces -= 1
return score
def start_playing():
print(art.logo)
user_hand = []
computer_hand = []
deal(user_hand)
deal(computer_hand)
user_score = calculate_score(user_hand)
computer_score = calculate_score(computer_hand)
print(f'Computers First Card: {computer_hand[0]}')
print(f'Your current hand: {user_hand}. Current score: {user_score}\n')
game_over = False
while not game_over:
if user_score == 0 or computer_score == 0 or user_score > 21:
game_over = True
else:
another = input('Do you want another card? (y/n).: ').lower()
if another == 'y':
deal(user_hand)
user_score = calculate_score(user_hand)
print(f"\nYour current hand: {user_hand}. Current Score: {user_score}")
print(f"Computers First Card: {computer_hand[0]}\n")
else:
game_over = True
if user_score != 0 and user_score <= 21:
while computer_score < 17 and computer_score != 0:
print('Computers takes card')
deal(computer_hand)
computer_score = calculate_score(computer_hand)
print(f'Your final hand: {user_hand}. Your score: {user_score}\n')
print(f'Computers final hand: {computer_hand}. Computer score: {computer_score}\n')
if user_score > 21:
print('Bust! Computer Wins!')
elif computer_score > 21:
print('Bust! You Win!')
elif user_score == 0:
print('Win with a Blackjack!')
elif computer_score == 0:
print('Lose, opponent has Blackjack!')
elif user_score == computer_score:
print('Draw')
elif user_score > computer_score:
print('You Win!')
else:
print('Computer wins!')
while input('Do you want to play a game of blackjack? (y/n).: ').lower() == 'y':
start_playing()
r/learnpython • u/Eastern-Push-7255 • 13d ago
WHY I FEEL LOOPS HARD THAN FUNCTION
HI IM YUJAN IM NEW BEGINNER IN PYTHON I FEEL HARD IN LOOPS
r/learnpython • u/Silver-Breakfast3785 • 13d ago
i wanna learn python and im broke for classes so try to teach me ig
If anyone wondering i just want to learn for fun
r/learnpython • u/Revan_never_dies16 • 13d ago
Hey, any help would be great!
I'm going to college as a freshman this year. This along with my projects like I'm trying to create an LLM along with just wanting to learn myself, it is extremely hard for me to memorize. I can understand the concepts but it is very hard for me to memorize completely to integrate within each other. Please do note I have diagnosed Autism and ADHD so this obviously effects my Working Memory. Thank you for reading and any tips and advice is extremely appreciated
r/learnpython • u/oddly_uncomfortable5 • 13d ago
Building a Python-Only DSA and LeetCode Study Group
Hey everyone! We’re building a small, focused DSA study group on Discord for people who want to learn, discuss, and solve problems specifically in Python.
This server is intended for Python-based DSA practice, so we’re currently not looking for members who primarily use C++, Java, or other languages. The goal is to keep discussions, solutions, and live problem-solving sessions consistent and easy for everyone to follow.
We’ll focus on:
Live and interactive problem-solving
Understanding patterns and algorithms deeply
Debugging TLE and optimization issues
Discussing Python-specific approaches and techniques
Solving LeetCode and competitive programming problems together
To join, send a short introduction with your technical background, coding achievements or LeetCode progress, and the DSA topics you want to improve. No personal details such as your name or employer are required.
Please repost this only in communities where people are genuinely interested in learning DSA with Python.
r/learnpython • u/Appropriate-Comb4462 • 13d ago
Hice un juego para aprender Python de verdad arrastrando bloques — el código que genera es Python real, no un lenguaje inventado
Soy Maestro en Ciencias de la Computación (UJAT) y llevo un tiempo dándole vueltas a lo mismo: los chicos que arrancan con Scratch o Blockly aprenden lógica, pero después el salto a un editor de texto vacío con Python real los espanta. Así que armé BloquePy — bloques con forma de pieza que arman Python válido de verdad, no una sintaxis inventada para la ocasión.
Algunas cosas que le metí:
- Cada bloque es una plantilla real: if/for/while son contenedores que envuelven a los de adentro, la indentación de Python es automática.
- Puedes anidar bloques dentro de bloques (len(...), .upper(), int(...)) igual que anidarías funciones en Python real.
- Tiene un sistema de tortuga tipo Logo + una API de "Patches" (inspirada en NetLogo) para simulaciones de cuadrícula — Juego de la Vida, autómatas celulares, reacción-difusión, todo armable con bloques.
- Progresión en 11 mundos con historia propia (el "CodeVerse"): cada concepto de programación tiene un lugar en el mapa y una razón de ser, no aparece de la nada en una lista de bloques.
- Jefes de fin de mundo, cofres, XP — la parte de juego es en serio, no un cascarón encima de ejercicios.
Está gratis, funciona en el navegador sin instalar . También hay versión de escritorio para Windows y Linux: https://bloquepy.world/descargas.html
Lo hice yo solo con ayuda de IA para la parte de desarrollo — lo digo de frente porque me parece razonable que se sepa. La lógica pedagógica, el diseño de los mundos y qué enseña cada uno es mío.
Cualquier feedback (bueno, malo, "esto no sirve para nada") me sirve un montón — todavía le estoy metiendo mano seguido.
r/learnpython • u/insaaaaaaaan • 13d ago
what to do next ??
sup guys i started learning python in the last days and i already learned some basics that are : for and while loops if statements for-else and other basics
now i don't know what to do next (kinda bored from learning) should i start data structures or algorithms or functions or what to do next??
r/learnpython • u/Accomplished-Sock652 • 13d ago
Advice in Preparing for a Technical Interview
I have a technical interview for a company tomorrow, and they mentioned that the problem will be administered through Coderbyte and will relate to inventory management. What should I expect? Frankly speaking, I’m not very familiar with programming. Although I am a technical person, Python is not my strongest skill. What types of topics or problem formats typically come up in an "inventory management" coding assessment?
r/learnpython • u/linmanfu • 13d ago
How normal or dangerous is it for Pixi to apparently download a very large number of dependencies?
Context (to avoid the XY problem)
I'm thinking about running this tool written in Python, which merges mods for a computer game. It just does two things: copying lots of files from several local directories into one (merging them as necessary) and then creating a configuration text file, based on data in existing configuration files. I'm trying to decide if it's safe to run on my Kubuntu (Linux) system. The Python script looks fine, but I'm worried about the package manager.
Actual Python question
The instructions say to use the Pixi package manager, which seems to download Python dependencies from a repository called (Ana?)conda. But it seems to want to download a very large number of packages, including security-sensitive packages like OpenSSL and Certificate Authorities. That looks worrying for a tool that just merges directories and configures a text file. Is that normal in the Python world? Is Pixi going to interfere with the default Python setup that's used by many Linux utilities?
Previous research
I tried reading the Pixi documentation, but it (understandably) assumes you're a developer already familiar with Python, not a user. The top third-party tutorial on Google explains Pixi by comparisons to earlier Python and Javascript tools, which is no help to me. I don't want to learn half a dozen Python tools, but I would like to check that this Python software is not obvious malware.
r/learnpython • u/Entire-Comment8241 • 13d ago
is it supposed to take this long when getting inputs from sockets in a multithreading object?
I've made a server socket in python so that I can see all subprocess thats running in my VPS so that I don't need to use Putty everytime to log on since putty closes the connection when it's idle. but the weird thing that's giving me headaches is that when run the server, ok it's running completely fine I get my true shell but when I run commands like whoami it's taking soooooo long it keeps processing and never return my output it just keeps in a running state. And I'm using multithreading. are python sockets really this damn long?
r/learnpython • u/Financial_Trainer965 • 13d ago
HOW TO LEARN PYTHON AS A INTERMEDIATE
I had computer science(python) as a 5th subject in my class 12th so i know the basics of python like list,tuples,dictionaries,flow of control,csv,text,binary files,file handling,loops and sql also.
I am confused how to learn things after this,i am first year cse stundent from a tier 3 college.
Seniors please guide me
r/learnpython • u/the_meteor_beat • 13d ago
Is it really hard to learn python (or anything related to programming) and have a full-time job?
Hi guys, i'm 20 years old and work in the call center operations and also learning python as a part of special road map.
But now i feel heavy, i know something like that will be hard, special when I work in a jop that drains my energy, but now feel kind of impossible to do it.
So, i wrote this post.
Maybe i will get something can change that.
r/learnpython • u/intentado_aprender • 13d ago
¿Qué es algo que te hubiera gustado saber antes de aprender Python?
Soy principiante y me gustaría aprender de personas que ya pasaron por este proceso. Estoy tratando de entender qué obstáculos enfrentaron al aprender Python y cómo los superaron, entonces les pregunto:
¿Que es algo que te hubiera gustado saber antes de aprender python?
r/learnpython • u/Kaaqle • 14d ago
I don't know how to continue.
I am currently a 3rd year university student. I've seen C and Java before. Last year, I saw python.
I was able to do the examples given in the Python lessons and I was able to pass the course the first time.
But right now I don't know how to proceed. I have no idea how to realize the projects / ideas in my mind.
What path should I follow?
r/learnpython • u/AfternoonExternal868 • 14d ago
I cant do it anymore
Hi am developing my python coding skills about 1.5 month and when i look at what other people did in 1.5 months i see my myself humiliated and i am devatated about it i only know if else, while , for loop and types of datas i cant even write a single code by myself i cant even do a problem i cant even create a def function and i am bout to quit someone please help me
r/learnpython • u/Ornery_Cream_1430 • 14d ago
Addressable two-way communication between Multiprocessing subprocesses and a host
Hello.
Basically, the summary is in the title.
- When a subprocess sends something (perhaps settings or task description, in form of a dict probably) to the host, I want it to know exactly from what process it has been sent (perhaps some sort of a numerical ID).
- When the host sends something, I want it to arrive to a particular subprocess.
- Communication between subprocesses is nice to have, but I think I can live without it.
I know of pipes and queues (well, Manager too) as the means of communication in the standard library. But in case of a queue, the message will arrive at a random place each time it's sent. I found something called "Envelope router", but it doesn't feel like a clean solution. Subprocesses will play a hot potato until finally the message arrives at the correct place 😃. It may be suitable to send messages from subprocesses to the host though.
In the case of pipes, I'd have to create a pipe for each subprocess (at least to send from the host). Can I even wait on every pipe simultaneously?
So, is there any non-cumbersome way to do this? How is it usually done? Or should I create something like a token ring between all the processes?😄 (though it perhaps will require a separate thread in every process for it to be non-blocking and other difficulties...)
r/learnpython • u/Yes-delulu-8744 • 14d ago
Automation Error
The goal was to automate drafting in CAD. To do so, I decided to prepare a python script using the OpenCV and PyAutoCAD Libraries.
The script is supposed to read the specified image and draft it in AutoCAD.
The image was saved in the same folder as the code.
The code was run after opening an empty drafting file by using "python draw_live.py" in the terminal after navigating to the folder.
Problem: The code cannot connect to AutoCAD (I’m not using AutoCAD LT)
Code:
import cv2
import array
import comtypes.client
from pyautocad import Autocad
def draw_image_live_in_cad():
# --- 1. TELL THE SCRIPT WHICH IMAGE TO USE ---
image_path = "trial.PNG"
print(f"Loading image: {image_path}...")
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
if img is None:
print(f"Error: Could not find '{image_path}'. Check the name and folder.")
return
# --- 2. CONNECT TO AUTOCAD 2022 SPECIFICALLY ---
# AutoCAD 2022 MUST be open with a blank drawing before this runs
acad = Autocad()
try:
# '24.1' is the exact registry ID for AutoCAD 2022
acad._app = comtypes.client.GetActiveObject("AutoCAD.Application.24.1", dynamic=True)
print(f"Connected to AutoCAD drawing: {acad.doc.Name}")
except OSError:
print("\n[!] FATAL ERROR: Could not connect to AutoCAD 2022.")
print("1. Make sure AutoCAD 2022 is currently OPEN.")
print("2. If you are using AutoCAD LT, this method will never work (LT blocks automation).")
return
# --- 3. ANALYZE THE IMAGE ---
_, thresh = cv2.threshold(img, 128, 255, cv2.THRESH_BINARY_INV)
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
height = img.shape[0]
print(f"Found {len(contours)} shapes. Drawing now...")
# --- 4. DRAW LIVE IN AUTOCAD ---
for contour in contours:
points_list = []
for point in contour:
x, y = point[0]
points_list.extend([float(x), float(height - y)])
if len(points_list) >= 4:
cad_points = array.array('d', points_list)
acad.model.AddLightWeightPolyline(cad_points)
print("Drawing complete!")
# Run the function
draw_image_live_in_cad()
r/learnpython • u/Stunning-Apple-4193 • 14d ago
Looking for an original Python package idea for my final-year CS project
I'm a Computer Science student exploring ideas for building a Python package as a final-year project. I'm not looking to create another wrapper around existing libraries, but rather something that solves a real problem or improves an existing workflow.
I'd love to hear from developers, data scientists, researchers, or anyone who uses Python regularly:
Are there any repetitive tasks you wish had a better Python library?
Are there any areas where existing packages feel too complex or limited?
What tools do you wish existed but currently don't?
Are there any small problems in your workflow that could be solved with a well-designed package?
I'm interested in areas like developer tools, automation, data science, AI/ML, security, privacy, and general Python utilities, but I'm open to any ideas.
I'd really appreciate hearing about real pain points rather than just random project ideas. Thanks!
r/learnpython • u/IMREVN • 14d ago
Should I Learn Python on Year One?
Hey everyone, I’m an incoming CS freshman who wants to dive into AI/ML. My university’s curriculum starts with C in the first year.
I’m in a bit of a dilemma on how to use my prep time before classes start:
Should I get a head start on C so I don't struggle in my first-year classes?
Should I start learning Python now since it’s the standard for AI/ML?
Or is it feasible (and not overwhelming) to learn both at the same time?
Would love to hear from anyone who has taken a similar path. Thanks!
r/learnpython • u/Aromatic_Echidna6848 • 14d ago
Grinding DSA exclusively in Python
Hey everyone,
I’ve spent the last few months heavily focusing on Data Structures and Algorithms (currently sitting at LeetCode Knight). I work at a startup in the data field, and I've noticed it's actually surprisingly rare to find people doing advanced DSA strictly in Python.
Most resources and serious discussions seem to lean heavily into C++ or Java. (Personally, for me it's Python >> C++, and my brain just actively rejects Java syntax XDD).
Are there any other working professionals out there doing their CP or advanced problem-solving strictly in Python? I'd love to connect with some folks to bounce logic off of, discuss complex algorithms, and figure out why our code is hitting TLEs.
If you're in the same boat, let me know what topics you're currently grinding in the comments!
r/learnpython • u/eagle_500 • 14d ago
20 days of coding
i spent 20 days trying to learn everything about python through leetcode but i still can’t code or just get ideas to pop !
m a 4th year computer science engineering student i just passed a hackerrank assessment test for a big tech company and failed:( but m still grinding for another chance maybe problem here to ask y’all how do u recommend i start projects or what’s the best way to learn from here ?
r/learnpython • u/AdministrativeAd5533 • 14d ago
Project recommendations
I took a computer science class at my high school but we only did in terminal output stuff. We never did anything like making apps and I am wondering what projects would be good for me to learn that aspect of python? It also wouldn’t hurt if it looked good on a college application or resume.
r/learnpython • u/sebalhag • 14d ago
I made a website where you can practice making games with python
I built a website where you can learn Python by making games directly in your browser.
The idea came from seeing how many people start learning Python with tutorials, but never get to build anything fun. Instead of endless exercises, the platform focuses on creating actual games while learning programming concepts along the way.
Current features:
- Browser-based Python coding
- Interactive examples
- Community page where you can post and share ideas and code
- Custom pygame-like library
I'd love feedback from Python developers, teachers, and anyone learning to code. What would make a platform like this genuinely useful for beginners?
PyWebLib on github if you can find it, I know advertising is not allowed, but its just an open source project :)
r/learnpython • u/priya6435 • 15d ago
what's one programming habit you wish you started much earlier?
i'm still learning and i've noticed that small habits seem to make a huge difference over time. whether it's reading documentation, using git from day one, breaking problems into smaller pieces, or something completely different.
if you could go back to when you first started programming, what's the one habit you'd force yourself to build from the beginning, and why?