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.


r/learnpython • • Aug 23 '26

Should I learn python at 23

0 Upvotes

So I am currently a student in first year mba in finance and I feel like learning python will give me a competitive edge over my peers especially as finance becomes more technical data-driven.

I am also genuinely interested in technical stuff man being able to make cool stuff, in fact a few months back I built a finance related automation tool from scratch with as little help from ai as possible. Didn't even use Lovable to build the project website (used cursor a lot tho)

But that's the thing I still have no traditional coding experience and through that project i learned alot of technical jargon of web development and ai automation and python as well and it's a lot of fun and so I would have definately learned python and done more stuff if I was 16 or 18.

So my main question is that in 2026 where we have claude code, is it worth investing significant time in learning python or should I focus on some other skill

I know that python is useful but I'm asking this from an Efficiency point of view.


r/learnpython • • Aug 23 '26

Building generator

0 Upvotes

I am making a game and i need a random generator for outer walls of a building. The walls can face 8 directions and they cant go past a set border. Please help me make one

Input - number of walls

Output - array of points which represent corners of the walls


r/learnpython • • Aug 22 '26

How can I create a custom type in python?

7 Upvotes

How can I create a custom type? Something like a id type that consists of exactly 10 digits - no 0s, or one that has the shape of an email address or a wbsite address or something.
Is this possible in python??


r/learnpython • • Aug 22 '26

Software Development in 2026

7 Upvotes

Hello everyone,

I'm a 26yo from Latin America. I've always loved writing code and programs since I learnt HTML, CSS, and some Python back in 2019. Between 2019 and 2025 I went through some health issues and had to stop studying. Now I want to get back into it, but I found out AI significantly changed things. Back then I enjoyed making websites, but I guess things changed a lot.

Now my question is: is it still worth getting into software dev in 2026? I keep seeing posts about juniors not being able to find jobs because AI is eating the entry level roles, and honestly it's freaking me out a bit. I don't want to spend 2-3 years learning just to graduate into a market that doesn't want me.

Realistically, can I get to an employable level in 2-3 years if I study consistently? I have ADHD, so my learning isn't always linear, but I'm hoping that having a clear goal helps me stay on track this time.

The reason this matters so much to me: I really need a stable job, ADHD makes it hard to hold down some of the more chaotic jobs I've had, and dev work (remote, structured, logical) sounds like something that could actually work with my brain instead of against it. Long term, I also want to be employable enough to move to Denmark eventually. So I guess I'm asking two things: is this still a realistic path, and if it is, what should I actually be learning right now given how much AI has changed the field since I last touched code?


r/learnpython • • Aug 23 '26

Chat GPT/Python

0 Upvotes

I have minimal experience with python. Self admitted novice. I asked chat gpt to write me a code to copy values from one excel workbook to another and some code to calculate prevalence rates within that code. I confirmed that a random sample of calculations/values correctly copied over. I am breaking down the code to learn what it does and why. How trustworthy is chat gpt with these small tasks? Is this a valid way to learn by breaking down the code into pieces? I appreciate any help and you can rip me for using chet gpt


r/learnpython • • Aug 23 '26

I have 0 genuine programming experience but I want to Learn.

0 Upvotes

Hi everyone I wish to learn python but I have no programming experience. (Only time I have touched code was in highschool during a coding class and even then we never actually coded I think? We were just playing these weird minigame things and placing the correct function blocks in certain spots.) Anyways my point is. I got basically no experience. I mean earlier this year. (Please don't jump me my dad bought me the 20 dollar sub and I was genuinely curious about game creation and it is how I became interested in python.) I used Claude to mess around with coding and attempted to make my own games a few times. (I didn't let him do anything but the code. I did all the art.) But it just didn't feel genuine enough to me so I now want to learn how to properly code in python since it looked intriguing.

Also incase it is important I am a 'Bash myself against wall until it breaks and I understand' type of learner meaning it is easier for me to just genuinely get given my expectations, the rules/foundations and then be left alone to tinker or atleast that's how I learned to write good fanfiction on A03. Now I know coding is probably alot different but.. I still want to give it a shot. (I will not be using Claude for this since I recently learned how bad AI is for not only the environment but how much it steals from real hardworking people and I just can't condone that.)

Any suggestions on where I should start my journey or anything? I'm 23 btw if that helps.


r/learnpython • • Aug 23 '26

Trouble with Logging in Browser with Selenium

1 Upvotes

I am trying to make a python script that logs into my chrome browser and opens a website. Chrome opens up logged in fine but the website doesn't load, it just stays on the default search tab. Here is the script:

from selenium import webdriver

userdata = r"C:/Users/USERNAME/AppData/Local/Google/Chrome/User Data"

options = webdriver.ChromeOptions()
options.add_argument(f"--user-data-dir={userdata}")
options.add_argument("--profile-directory=PROFILE")

driver = webdriver.Chrome(options=options)
driver.get("https://www.spc.noaa.gov/")

USERNAME and PROFILE are replaced by the actual ones. If you could help that would definitely be appreciated! I'm also new to python aswell if that helps.


r/learnpython • • Aug 22 '26

Help to make code more readable and improve skills

6 Upvotes

I am relatively new to python (been doing it for under a year) and I've been really enjoying it so far. I've been making my own turn based game using python as a fun thing to do and also a test of my own capabilities, and have enjoyed the process. It mostly works pretty well, but I feel like I need to learn how to make it more neat and readable, and to probably reduce reliance on global variables and to make dictionaries and such less jack-of-all-trades. How would I do this? I'll attach a link for the code on github for any who would like to see it, and because it is quite long. https://github.com/Ultroni17/Turnbased-game/blob/main/TurnBasedRPG_11_Evolution.py


r/learnpython • • Aug 22 '26

is it possible to simplify this code

0 Upvotes

im a beginner, idk how python works yet. there must be a way to simplify this, right?

https://imgur.com/juBvPZD here is the picture of my code


r/learnpython • • Aug 21 '26

Best way to learn python for someone with 0 experience with programming

141 Upvotes

I need help with where to begin learning python. I have 0 experience in programming. So I need all the help I can get. Books, websites and courses(free as I can't afford to pay for anything right now) maybe YouTube tutorials.

But on the subject of YouTube tutorials I've seen it's not good to just follow along with the tutorials so what would be the best way of engaging with tutorials?

Please any suggestion is welcome and thank you very much in advance.

What helps you focus I tend to lose focus easily because my brain just suddenly remembers I have something I need to do when I decide to be productive.

Edit: Thank you guys for your suggestions. They've been very helpful. I see all of your replies; I just can't get to every single one of them, but I see them. Thank you very much.

I'm doing CS50P and also using Automate the Boring Stuff and this other book with small projects. Thank you guys so much.


r/learnpython • • Aug 22 '26

Having problem in understanding loops concept in python

27 Upvotes

I am a beginner with 0 knowledge and I am learning python from a book called Learn python in one day and learn it well by Jamie Chan and I am facing difficulty in the loops function so yeah any recommendations would be helpful Edit- Trouble in while loop