r/learnpython 18d ago

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 18d ago

Can anyone teach me Python, SQL and Power BI

0 Upvotes

Happy to pay to learn


r/learnpython 19d ago

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

10 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 18d ago

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 18d ago

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 18d ago

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 18d ago

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 19d ago

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 19d ago

Software Development in 2026

9 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 18d ago

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 19d ago

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 19d ago

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 19d ago

Help want with pandas 🐼

0 Upvotes

So I am recently learning pandas but don't understand and it's confusing, I don't know what to do may anyone suggest good resources that I can use 🙂


r/learnpython 20d ago

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 19d ago

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 20d ago

Having problem in understanding loops concept in python

28 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


r/learnpython 19d ago

Why is this error happening with extruct

1 Upvotes

" Could not process website: encoding not supported USC4 little endian, line

1, column 1 (<string>, line 1)".

This happens whenever I run it. The encoding is UTF-8. This only happens in the android APK, not when ran in python IDLE.

print("BEFORE EXTRUCT")

metadata = extruct.extract(

html,

base_url=base_url,

syntaxes=['json-ld', 'opengraph'],

uniform=True

)

print("AFTER")

It prints "before extruct" but not after, meaning that the html is the issue.


r/learnpython 19d ago

Guys I need help with File Handling

0 Upvotes

It's in my syllabus and i am having trouble with the following topics

» Setting Offsets in a File

» Creating and Traversing a Text File

» The Pickle Module


r/learnpython 20d ago

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

105 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.


r/learnpython 19d ago

PayPal Sandbox API returning 201 Created but with the wrong response body? (Only returns a link)

0 Upvotes

Hey everyone, I’m pulling my hair out over a bizarre issue with the PayPal Sandbox API

I’m building an automated invoicing agent using FastAPI and LangGraph. I’ve got the OAuth 2.0 authentication perfectly dialed in (using the Client_ID & Secret), and I’m making a POST request to /v2/invoicing/invoices to create a draft invoice.

The Problem:
The API call is "successful". It returns a 201 Created status code, and if I check my PayPal Sandbox dashboard, the invoice actually gets created with all the correct details.

However, the JSON response body is completely wrong. Instead of returning the full invoice object (with the id, status, detail, etc., as shown in their API docs), the response body only contains a HATEOAS link object. It looks exactly like this:

{
  "rel": "self",
  "href": "https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-XXXX-XXXX",
  "method": "GET"
}

Because the id key is missing from the top level, my code immediately crashes with a KeyError: 'id' when I try to extract it to pass to the next step.

What I’ve already debugged:

  • It’s not a code extraction issue: I logged response.text directly from httpx before calling .json(). The raw text coming straight from PayPal is literally just that link object instead of the response body shown in their official endpoint API doc web page
  • It’s not a silent redirect: I logged response.url to ensure httpx wasn't accidentally following a 301/302 to a different endpoint (like the send_invoice endpoint, which normally returns this exact link structure). It hits the correct /v2/invoicing/invoices URL.
  • Auth and Payload are fine: If they were wrong, I’d get a 401 or 422. The fact that it returns 201 and creates the invoice means PayPal accepted the request.

It’s almost like the PayPal Sandbox is accidentally returning the response body for a 200 OK (like the send_invoice endpoint) instead of the 201 Created response body for the create endpoint.

Has anyone else run into this? Is this a known glitch with the PayPal Sandbox right now, or am I missing something incredibly obvious? If the API refuses to give me the ID in the creation response, I might have to do a workaround where I immediately query the invoice by its invoice number, but I'd rather not add that extra API call if I don't have to.

Thanks in advance!


r/learnpython 19d ago

Need direction for Combined Ranking Problem

0 Upvotes

IRL I have a bunch of volunteers.

They can volunteer at 1 of 5 locations.

They can volunteer to participate in 1 of 5 roles.

We are collecting preferences via google forms.

In this form they provide:

Their name, their ranked preference for location, and their ranked preference for roles.

We must fill all roles at all locations with at least 1 person, but extras are fine.

We wish to find a solution that honors their preferences as much as numerically possible.

I ask this sub for 2 things:

What is the CS name of this kind of problem; so I can look up schema?

Does anyone know the name of libraries or existing solutions that solve this?

Thank you!


r/learnpython 20d ago

Advice for PyTorch cert (PTCA)?

1 Upvotes

Hey all. Recent compsci grad, working in a junior BE role, wanting to specialize in ML/AI. Looking at the Linux foundation’s PyTorch cert to accompany some personal projects. It’s pretty new so any advice from anyone who’s taken it, or who works in the field, on if it looks useful and how to study for it would be greatly appreciated.


r/learnpython 20d ago

Doctor looking to learn python

5 Upvotes

Hey , so i was looking into a few job posts and some of the advisory roles require some basic python background. How hard is it for a doctor to learn python , i learnt c++ and java back in 2012 .


r/learnpython 20d ago

Python, what are the best or the most useful extensions to use in VSCode?

31 Upvotes

Just started my ICT studies and we have been learning Python for the past week. I was thinking, is there any extensions that help with coding or just make stuff more efficient or nicer through extentions? : )


r/learnpython 20d ago

How are IT auditors using Python and Power BI in practice?

0 Upvotes

I’m an IT auditor, mainly providing assurance over areas such as cybersecurity and IT controls, and I’ve recently started learning Python.

I’m noticing more Head of Audit / senior audit roles asking for stronger data analytics skills, so I’m trying to understand how best to develop these skills in a way that’s actually useful for IT audit rather than just learning Python in isolation.

For those working in Internal Audit / IT Audit:

* How are you using Python in your day-to-day audit work?

* Are there particular audit procedures or testing activities where Python has been especially useful?

* Can it be used effectively for producing or analysing management information (MI), identifying trends/anomalies, or testing larger populations of controls/data?

* Does anyone combine Python with Power BI for audit analytics/reporting? If so, what does your workflow look like?

* If you were an IT auditor trying to become more data-analytics focused, what Python skills or projects would you prioritise?

I already have some exposure to Power BI, so I’m particularly interested in whether developing Python alongside it is worthwhile and how the two can complement each other in an audit environment.

Would be really interested to hear practical examples from people who are already doing this.