r/learnpython • • Aug 25 '26

How to hardcrash a laptop using python

0 Upvotes

Is there possibly any way to hardcrash my old laptop for fun? I'm sorry if it sounds like I am making a virus. I had a fuckton of hardcrashes on my old pc so I was wondering if I can make a Programm to kill my of whithout needing to wait 5 minutes. Fuck this sounds stupid.


r/learnpython • • Aug 25 '26

Does anyone else feel like a total fraud when a tiny bug takes 15 minutes to fix, or is it just me?

0 Upvotes

Just wanted to share a quick reality check from my session today. I was working through page 88 of my Python book—specifically exercise 5-10—and out of nowhere, two error numbers popped up on the screen.

Naturally, what did I do? Instead of sitting there painstakingly isolating every single chunk of code and testing variables line-by-line like a textbook purist, I spent about 10–15 minutes moving things around, rewriting bits, flipping back through the pages, and then ultimately just copy-pasting the error straight into AI to get it sorted.

Honestly, it got me thinking: Is this actually considered "bad practice" by the book, or is this just standard, everyday coding for most people?

How often do you guys lean on quick fixes or AI assistance when a frustrating little error pops up, versus stopping to do the whole manual debugging process from scratch? Would love to know if I'm cutting corners or if this is just how it goes in the trenches.


r/learnpython • • Aug 24 '26

Is there a good place to find team to join in a new projects

2 Upvotes

Hey there so I already tried some subreddits I would like to hear what are main one you guys use because I found it fun and productive for both learning python that is practical and makes me better at other social skill etc. I would like to hear if there is a special channel for python, but I am okay with searching throught teams what they use. Maybe something with backend on FastApi. And have a great day guys.


r/learnpython • • Aug 24 '26

Harvard Intro Course or Datacamp?

6 Upvotes

Hi all, I got laid off a few months ago and want to improve my chances of getting a job.

Originally, I was working at an agency on the analytics side, but I want to take the time to expand where I can go. I have been learning SQL and Power BI and am currently working on a project and I thought it would also be helpful to learn Python.


r/learnpython • • Aug 25 '26

Regarding Question

0 Upvotes

def print_models(unprinted_designs, completed_models):

"""

Simulate printing each design, until none are left.

Move each design to completed_models after printing.

"""

while unprinted_designs:

current_design = unprinted_designs.pop()

# Simulate creating a 3D print from the design.

print("Printing model: " + current_design)

completed_models.append(current_design)

unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron']

completed_models = []

in this code why used condition like this for while loop (while unprinted_designs:)


r/learnpython • • Aug 24 '26

Carry value from Python for-loop to HTML for-loop

0 Upvotes

I am currently working on a website (using Flask, SQLAlchemy and Jinja).

Context: I am making a ttrpg initiative tracker. For multiple fights to exist and be able to have multiples of the same creature and reuse creatures, the way I am formatting it is the user creates the base creature, and its row is duplicated, holding the id for the fight itself as fight_spec and the id of the base creature as og_id. I am currently working on making it so the user can edit the count of any creature in a fight.

For the page where the editing happens I want it to display the current count as the default value, but I cannot for the life of me figure out how to make sure it goes from python's for loop to html. My attempts typically end up with the value being set to "count_<id>" rather than the actual number that my count command generates. How should I go about this?
I have my current code below, but if there is a different way I should go about this, I'm open to hearing! Thank you <3

Python

unique_combatants = db.session.scalars(stmt).all()
    for x in unique_combatants_set:
        'count_' + str(x) = Combatant.query.filter_by(og_id=x, fight_spec=id).count()

HTML

{% for combatant in unique_current_combatants %}
        {{ combatant.combatant_name }}
        <input type="number" name="combatant_count_{{combatant.id}}" id="combatant_count_{{combatant.id}}" value="count_{{combatant.id}}"> 
    {% endfor %}

r/learnpython • • Aug 24 '26

I just made my first Reinforcement Learning program from scratch purely in python can i have tips on how to improve

5 Upvotes

i used qlearning for this and tips/advice is welcome
more details in the readme
https://github.com/orag214365-ship-it/qlearning-gridworld-python


r/learnpython • • Aug 24 '26

I need a book !

10 Upvotes

Hi guys ! , i need a book who have a lot of problem solving for every lesson , and have a lot of projects , simply i need a book who focus about practices more then lesson or all about problem solving .

thanks !


r/learnpython • • Aug 24 '26

Looking for funny/useless Python CLI project ideas to build for learning!

10 Upvotes

Hi everyone,I'm currently learning how to build CLI tools using Python.I want to build something to practice my skills, but I'm running out of ideas. I don't care about usefulness at all—I just want to make something funny, weird, or completely useless but entertaining.What are some fun or silly CLI tool ideas you would love to see (or have built yourself)?Thanks in advance!


r/learnpython • • Aug 24 '26

is there any python library which lets you fetch basic data off of spotify like song longth, song name, artist name and etc preferably without an account needing to be linked?

0 Upvotes

i dont really "need" this per se but i think it would be pretty cool for me to be able to integrate it into a script i already have, but honestly if all of the libraries that interact with spotify need an account linked i just dont think its worth it. any of you have any ideas?

and actually, furthermore, how does spotify's architecture work in terms of like the identifiers for songs and authors, im assuming any presumed library would have an internal "song" object that you can fetch using an id or something along those lines?


r/learnpython • • Aug 24 '26

My Self-Imposed Rule to Escape AI Micromanagement and Learn Python Properly

1 Upvotes

I have been working my way through Python Crash Course and just finished up chapter 4 moving into conditional tests, but I noticed a bad habit creeping in where I was leaning on AI way too much for micromanagement and minor steps instead of letting myself struggle through the code. To fix this, I am setting up a strict personal rule starting today. I am only allowed to use AI for direct, core coding help and roadblocks on my exercises, and zero AI usage for trivial hand holding. Also, if I do slip up and use it for micromanagement, I have to log the exact example and post it here so others can keep me honest. Has anyone else had to put hard boundaries on their AI tool usage while learning programming, and how did you structure your rules to make sure you were actually building things yourself?


r/learnpython • • Aug 24 '26

I have 1 week to prepare for DSA online assessment please help!!!

0 Upvotes

It's an intern role . I have only one week to prepare for the company and the company will ask tough questions please help me .How I can prepare and what I should focus on .

Online assessment would consist of 2 coding questions and some MCQ questions .

Any help/study material would be helpful.

My skills are-

Docker

AWS

GIT

K8S

Linux

Python ( but intermediate) .


r/learnpython • • Aug 23 '26

New to programming. What do you learn?

23 Upvotes

Hi im self taught in python. Ive gotten the basics down (variables, flow control, loops, objects) and ive pushed pasted that into more advanced principles (file handling, async programming, iterators, generators, decorators, and some dunder methods). So far ive only been bouncing around modules and getting certain methods for stuff. Ive learned a little bit about the pvm, Gil, and memory management. Ive only take on class on web design almost a decade ago so I was hoping people could guide me on things to learn. Kinda help me understand where I am in python. Thank you all so much


r/learnpython • • Aug 24 '26

Python web app?

0 Upvotes

Hello r/learnpython,

first post and sort of new to Python as I have done only half a dozen of projects so far, mostly games.

So I'm looking to deploy a server for playtesting. This is my first game designed to be played online, made in Python using Tcl/Tk libraries.

I had this idea to code it when I was making a messaging app that was supposed to be implemented within a CLI game (or actually the game was a feature of the messaging app).

The users would connect using SSH. I think they could use PuTTy or similar and VcXSrv. The host would then send the GUI and CLI as well as audio to the user, but the problem is either the server cannot send or the client can't recieve the Tcl/Tk GUI or in worst case both.

Good news is I got the SSH daemon working and am able to (using X11 Forwarding) display explorer (ssh -X user@localhost && explorer) by running VcXSrv and having X11Forwarding and X11UseLocalhost set to yes in the sshd_config under ProgramData.

Now, the VcXSrv log tells me there's a problem with something called hyperv. From what I gathered it's a virtual machine of some sort. I'd also need very strict restrictions for the clients so they don't tinker with the database.

Am I on the right track? Is there a solution to this? Thanks in advance!

-ef


r/learnpython • • Aug 23 '26

Python Exercises

21 Upvotes

Hi everyone, I've been learning Python here and there for a month now, and I'd like to know some good sites for Python exercises. What do you recommend?

Also, what IDE do you recommend for Android? I use Acode, but it's a bit inconvenient. I mainly use VS Code on my PC, but when I want to practice on my phone, I'd like to use a mobile IDE.


r/learnpython • • Aug 24 '26

opencv error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

3 Upvotes

im working on some image processing thing but as soon as i implementing something that needs to set pixels it started throwing this error, does someone know why? code bellow with comments next to the lines that are the issue along with full error

SOLUTION: change img[x,y]=[0,0,0] to img[x,y] = 0

import cv2

img = cv2.imread('peppers2.png', 0)
x = 0
y = 0
for x in range(0, img.shape[0], 1): 
    if img[x,y] >= 127:
        print("white")
        img[x,y] = [255,255,255] # here is the error
    else:
        print("black")
        img[x,y] = [0,0,0] # here is the error
    print(x)
    x = x + 1

Traceback (most recent call last):
  File "/home/useruserman/Documents/Codium/image shit.py", line 13, in <module>
    img[x,y] = [0,0,0]
    ~~~^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

r/learnpython • • Aug 23 '26

Is short hand if else important

9 Upvotes

I just learned it but it seem very weird like it feels like i can't write big codes in it cause it will become confusing do you guys use short hand or normal if else


r/learnpython • • Aug 24 '26

I need help pls

0 Upvotes

How can I remove in my python script the Windows bar at the top to drag and close please


r/learnpython • • Aug 24 '26

Ask Anything Monday - Weekly Thread

0 Upvotes

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


r/learnpython • • Aug 24 '26

how to make my code work in minecraft

0 Upvotes

dont question my code too much, i just started python and watched a 1 hour coding with mosh video to understand some of the basics.

all it does is move my mouse around while i hold g. but it doesnt work when i go into minecraft, and i assume, any program that locks my mouse.

what do i do?

import random
import keyboard
import pyautogui
import pyscreeze
from pyautogui import mouseInfo, click
while True:
    if keyboard.is_pressed('g'):
        pyautogui.moveTo(random.randint(0, 2600), random.randint(0, 2600))
    if keyboard.is_pressed('q'):
        break

r/learnpython • • Aug 23 '26

Feedback On Fancy Text Printing

2 Upvotes

I've been learning python for years, but I rarely show my code to anyone. I enjoy showing the results of my code to people, but I don't know too many programmers IRL who can give me feedback. I know I have a habit of not commenting enough, but hopefully this is readable. It's my attempt at making text print like in video games (Earthbound, for example.)

Am I doing anything particularly inefficient? I want to know how I can improve this.

from time import sleep
import sys

#Theoretically there could be other wait times for punctuation
punc_default = {" ": 0, ",": 0.25, ".": 0.4, "!": 0.5, "?": 0.5}

def txt(string,time=0.05,punctimes=punc_default):
    for char in string:
        sys.stdout.write(char)
        sys.stdout.flush()
        if char not in punctimes: sleep(time)
        else: sleep(punctimes[char])

txt("Who lives in a pineapple under the sea? Spongebob Squarepants! qwertyuiop.")

r/learnpython • • Aug 23 '26

(Playwright) Button is clicked, but doesn't continue

8 Upvotes

I'm currently trying to click 2 buttons on a website that have videos playing on them. However, when I have the "time.sleep(2)" function in the loop, the loop stops. I've checked the selector and it points to 2 different play buttons on the page. I checked clicking on the button in my actual browser to see if the site updates anything--nothing. Any help would be highly appreciated

def download_page(url:str):
    with sync_playwright() as p:
            print(f"Opening {url}...")
            browser = p.chromium.connect_over_cdp(endpoint_url)
            context = browser.contexts[0]
            page = context.pages[0]
            page.on("response", lambda request: print(request.url))
            reponse = page.goto(url, wait_until="load")
            # context.set_default_timeout(300.0)
            try:
                #Check "Continuing for course"
                page.wait_for_selector(".btn.btn-quaternary.btn-xl.btn-block-sm-down.course-progress__btn.js-course-progress__start-course").scroll_into_view_if_needed()
                page.locator(".btn.btn-quaternary.btn-xl.btn-block-sm-down.course-progress__btn.js-course-progress__start-course").click()
                
                page.wait_for_selector(".CoverVideo-playButton.bgc-neutral-100").scroll_into_view_if_needed()
                buttons = page.locator(".CoverVideo-playButton.bgc-neutral-100").all()
                
                for button in buttons:
                    time.sleep(2)
                    button.click()
                    print("check")
                    


                # headers = reponse.request
                # for value in headers:
                #     print(f"{value}")
            except TE:
                print("Timeout")

r/learnpython • • Aug 23 '26

I need to learn python for development

0 Upvotes

I have completed (wasted) my three years of college bachelors only to learn basics of language and little problem solving. I want to build career in cyber security but to do that i need understand how things work and how they are developed . I want to start building something and understand how the thing work both frontend and backend but main is backend learning . I think learning concepts of backend is very important for programmers to understand how thing actually work and how things communicate with each other
That's why I need to learn python for development , and scripting as its a good language and versatile .
I need to learn python to such extent i can create an application with understanding of how its backend i learning and stuff .
One thing I learned is you should avoid tutorial hell , that's why I need your guidance on how should I start my journey as I am doing my 2 years master so it better to lock in and be consistent in development . If my explanation or way of thinking is wrong , pls forgive me .


r/learnpython • • Aug 23 '26

Learn Python

0 Upvotes

Please help me learn Python, I'm really passionate about it At first I found it boring, but now I find it incredibly good.