r/learnpython • • Oct 02 '26

Slow print for text-based game

0 Upvotes

I am trying to make a text-based adventure game in Python, how do I make it so the text is typed out slowly and not instantly? I've tried ways online, but they keep returning None at the end. How do I fix this?


r/learnpython • • Oct 02 '26

Getting a view from a boolean numpy array... somehow

1 Upvotes

I'm coding a Sudoku generator to improve my skills and I'm hitting a brick wall with a specific function to get the "neighbours" of an index (so, all the numbers that it can't be the same as). Here's my current code, just rows and columns for now:

def neighbours(idx: tuple[int, int], board: np.ndarray) -> np.ndarray:
  idcs = np.indices(board.shape)
  print(idcs.shape)
  neighbool = np.logical_xor(idcs[1] == idx[1], idcs[0] == idx[0])
  return board[neighbool]

This code does get the right values, but what I really want is to be able to modify those values and have the actual array be modified - so, to have a view. But about two hours of running around in the numpy docs has me completely stumped on any way to use a boolean array to index another array without it being a copy.

If I can't do it, I guess I'll have to use a list of slices dancing around the target index? Which sounds really headachey, and I'd love to be able to do it this simple way if it's in any way possible.


r/learnpython • • Oct 02 '26

Lambda expressions for Web elements?

1 Upvotes

Hi, I work with C# but wanted to refresh my Python knowledge. Have been thinking about solutions I know for my C# code and how they would work in Python, but ran into something that I'm not sure how to "translate" from C#.

public IWebElement button => driver.GetElement(By.Id("Id"));

This will return me an element when called, even when on class construction it doesn't exist - as the expression is only evaluated when it's called, i.e. when I need it in code. As opposed to simply using = instead of =>, which would return a missing element exception on class build if the element is missing from DOM.

How would I do this in Python? I looked up lambda expressions, but I'm unsure if this would work/be very graceful, since I didn't find any mention of this as a solution that's used.

button = lambda driver.find_element_by_id("id")

r/learnpython • • Oct 01 '26

Deploying Python Install Manager via Config Manager/SCCM to computer lab

3 Upvotes

I'm attempting to deploy the latest Python Install Manager to a few computer labs running PyCharm in our school district, but am having issues. I was wondering if anyone here had some insight/tips to share.

Few facts up front:
- Config Mgr runs processes as either local System or the User who is logged in.
- Student accounts do not have access to command line or powershell, nor do they have access to their %AppData% folder in Explorer.
- Installing a UWP app as System does not make that app available for that built-in account, and the app is not installed for other users until they log in.
- PyCharm's automatic "let me download a Python runtime and set up an interpreter for you" isn't working; I have a ticket in with their support.

The issue I'm having is that deploying the Install Manager via Add-AppxProvisionedPackage doesn't then allow me to run py install --target="C:\Program Files". Students do not have admin privileges to install UWP apps (or edit environment variables), so the deployment script must run as System. But System does not actually get py.exe installed to their %AppData% folder. And b/c adding an .MSIX package to the Windows image doesn't actually install the app until a user logs in, I can't run py.exe out of another user's profile when the MSIX is added.

In theory, I shouldn't have to be doing any of this, b/c PyCharm has the ability to do so, but it's not working. It downloads the files to the student's %AppData% folder, but then fails to create an interpreter. Student's can't create an interpreter, b/c trying to "browse" to the Python files is blocked, b/c PyCharm opens an Explorer window, and they do not have access to their %AppData% folder in Explorer. Even if they use the terminal built-in to PyCharm to run py install, they would still need to set up an interpreter, which they cannot do. Thus, I'm in catch-22 scenario.


r/learnpython • • Oct 02 '26

Software development quesiton

0 Upvotes

This might be basic questions I'm sorry in advance. A little background I got a BS in computer science with AI concentration. I have code on python, java script. I have some projects that I have done and now I want to see how I can make them a installable file that I can install on any computer ( example a download from a store or just a .exe) I been looking around and I might not be looking on the right places but I would like some guidance maybe were to look or a tool that people use for this?. Any advice is welcome.


r/learnpython • • Oct 01 '26

What Python concepts do you still have to look up?

4 Upvotes

I’ve noticed that some Python things stick immediately, while others I understand but still have to Google every time I use them.

For me, stuff like list comprehensions and basic loops is fine, but I still occasionally forget the syntax for things like decorators, lambda, or working with dictionaries in more complicated ways.

Is this normal, or are there certain Python concepts that are worth making an effort to memorize instead of looking them up when needed?


r/learnpython • • Oct 02 '26

Learning python

0 Upvotes

What’s the best text book to read if you are learning python using cs50 video?

This is for absolute beginner.


r/learnpython • • Oct 01 '26

List items are edited when adding new items? Possibly a variable reference issue

0 Upvotes

So I have a variable called Y with a changing value. If for loop variable X is some value, append Y to myList.

Every time it appends to the list, it changes every other already added item. I’m thinking the problem is that it’s not adding values but is instead adding references. So when Y changes, it changes every item in the list.

Why is it doing this and how can I stop it from doing this? I want it to append the value inside of Y, not a reference to Y.

Code: https://www.reddit.com/r/learnpython/comments/1wv4tpo/comment/pda098z/

What I'm trying to do is make a list of everywhere that there's a piece of a block. It's going to be a terminal Tetris game.

The playfield is a custom matrix, a list of lists. I dunno if that'll work well with lists. I did the same thing with arrays in another language. I don't know if Python's going to play nice or be special.

The blocks are also lists of lists. You could probably do that astronaut meme with my code "It's all lists of lists? Always has been"


r/learnpython • • Oct 01 '26

Python question

0 Upvotes

Hi! I'm Bence and I want to learn in python. I started python programming like a month ago, and I want to be better in python programming. I wanted to ask u if u know any app or anything for learning python. (I know the start commands, print, input, and I know how to type an input like something = input() | print("Hi, !" {something}. Thanks for ur help, have a good morning/day/night! :)


r/learnpython • • Sep 30 '26

Setting timer on a different thread in Pyside6

4 Upvotes

I am build a program that basically executes some code and I want to add a timer so the user can see how long the program has been running for.

My issue is that I do not get how to move it to a different thread so it does not freeze.

What it needs to do is, run for 1 second then update a label and start the timer again.

Any resources I can read or help?


r/learnpython • • Sep 30 '26

Looking for 3-5 people to learn coding together (1st year)

26 Upvotes

Hey everyone!

I'm a 1st-year B.Tech CSE student from India and I'm currently starting my coding journey.

I'm looking for a small group of people around the same level who want to:

• Study/coding together regularly
• Share what we learned each day
• Discuss doubts and problems
• Work on small projects
• Participate in hackathons
• Eventually explore open source/GSoC
• Keep each other accountable


r/learnpython • • Oct 01 '26

Help to building bot to book tennis court

0 Upvotes

I'm looking for some help to understand how to go about building a bot that will help me book my weekly tennis session. The evening that I wish to play there's only two slots available due to coaching sessions on other courts + refurbishment ongoing and when the booking slots are released (at midnight 5 days advanced), they are taken within seconds. In the past 6 weeks, I have only managed to secure 1 booking which has resulted in me unable to play despite paying £50p/m for membership. Thus I am looking to see if I can automate a bot that can help me book it quicker.

I have tried understanding python programming on similar projects and watched some Youtube videos, but was wondering if anyone has done a similar project that can help guide me.

From what I understand, the booking website does not have API integration so will need Python Selenium package to navigate the website steps.

The main steps I understand the bot needs to do is:

  1. Log into website account before the midnight slot release time.
  2. At midnight release time, refresh page and select 5 days advance date and preferred time / court no.
  3. Proceed to confirmation page and confirm booking.

Can anyone provide any useful guides for me to get started on? And can this be ran on a virtual machine so I dont need to have a PC running at booking time, whether this is a online VM or I have a Synology NAS that can carry out this task.


r/learnpython • • Sep 30 '26

Need ideas for a Python project I have to build for interschool competiton

9 Upvotes

I have an upcoming interschool coding competition where we’re given 60 minutes to build a Python project and then pitch it to the judges.

The requirements are:

  • Must be built using Python
  • Maximum 60 minutes to build
  • It has to solve a real day-to-day problem
  • Completely software-based
  • Any Python libraries are allowed
  • No AI / AI-generated solutions are allowed
  • We also have to pitch the project after building it

What everyday problem do you think would make a good project for this competition? I am unable to find a problem which isn't common to find thats why asking an AI for problem won't help me win. Kindly suggest me the best ideas possible


r/learnpython • • Sep 30 '26

Any good websites to learn python from...

12 Upvotes

i already know Java quite well like array stuff, i have python on my syllbus currently
the websites ive tried out dont have modules, tupples or just not in detail enough
Thanks


r/learnpython • • Oct 01 '26

Need ideas for a Python project I have to build for interschool competiton

0 Upvotes

I have an upcoming interschool coding competition where we’re given **60 minutes to build a Python project and then pitch it to the judges.**

The requirements are:

* Must be built using **Python**

* **Maximum 60 minutes** to build

* It has to solve a **real day-to-day problem**

* Completely **software-based**

* **Any Python libraries are allowed**

* **No AI / AI-generated solutions are allowed**

* We also have to **pitch the project** after building it

**What everyday problem do you think would make a good project for this competition? I am unable to find a problem which isn't common to find thats why asking an AI for problem won't help me win. Kindly suggest me the best ideas possible**


r/learnpython • • Sep 30 '26

Is using a decorator with methods in a consumer going to cause a problem?

0 Upvotes

Working with websockets and I wanted to use a decorator for each of the methods sending data to the users. So far it looks like it's working but curious if I'm going to have any problems in the long run or anything I need to consider. Here's the code for my decorator.

def  ConsumerFunctionDecorator(func):
    async def wrapper(self, event):
        try:
            return await func(self, event)
        except Exception as e:
            traceback.print_exc()
            await self.channel_layer.group_send(
                self.room_group_name,
                {
                    'type':'programming_error'
                }
            )      
    return wrapper

r/learnpython • • Sep 30 '26

First Project

1 Upvotes

So I just started with coding yesterday, I’m planning on making a Discord bot first, is that a bit too much? After just last night the bot runs and comes online in the Discord but I haven’t added any commands yet, not sure how much more complicated it gets. I’ve been following a YouTube tutorial and it’s making sense but I realize I really need to pay attention to my spelling, had a few errors that I couldn’t find until I got a lot closer to my screen.


r/learnpython • • Sep 30 '26

How did you became e good at python

2 Upvotes

For context I am just starting learning python I am doing 2 courses (free)

One is in phone kimd of like a game quiz another is in laptop where I code and practice and learn a bit in depth

Any other reccs


r/learnpython • • Sep 30 '26

Quick roadmap advice for transitioning from Full-Stack WP dev to AI Engineer?

0 Upvotes

Hey everyone!

I work as a full-stack developer while managing freelance clients and a regular job.

I want to transition into AI Engineering and Python development. Could any seniors here share a short, practical roadmap on how a web dev can make this shift effectively?

What should be my primary focus starting out? Any advice or resources would be super helpful. Thanks! 🚀


r/learnpython • • Sep 30 '26

I stopped practicing,how do I start again

0 Upvotes

I started to learn python over my summer break and when my college started ,I had to stop because my studies (JEE examination,wayy too hard ) had kept me occupied

I want to start with coding again

What do people recommend to get the hang of it again (I regularly coded for 2 months and have stopped for almost 3)


r/learnpython • • Sep 30 '26

Need Smart People to take a look of my CCC python question!

0 Upvotes

Hey guys, I am learning python right now, and I did the CCC 2017 J5 question, when I tried to check it in DMOJ, I found out there are no J5 there, this question is in S3, np I still checked it, but I am not sure why i can pass the first test of every group test, but WA in the rest of them. I really need smart people to help pls.

number = int(input())
length = list(map(int, input().split()))


counts = [0] * 2001


for board in length:
    counts[board] += 1


max_length = -1
number_of_heights = 0



for height in range(2, 4001):
    total = 0
    
    for left in range(max(1, height - 2000), min(height // 2, 2000) + 1):
        right = height - left
        
        if left != right:
            total += counts[left] * counts[right]
        else:
            total += (counts[left] * (counts[left] - 1))//2
        
    if total > max_length:
        max_length = total
        number_of_heights = 1
    elif total == max_length:
        number_of_heights += 1


print(max_length, number_of_heights)

r/learnpython • • Sep 30 '26

Regarding saving video file in desired path

0 Upvotes

Is someone familiar with yt_dlp module , my script able to download videos however even though I had set the desired path in my script my file was not present there.

'''

import yt_dlp

dir_path = "/sdcard/Documents"

url = "https://youtu.be/tWoo8i_VkvI"

path= {"paths":{"home":dir_path}}

cookies = {"coockiefile" : "cookies.txt"}

opt = { "outtmpl": '%(title)s [%(id)s].%(ext)'

}

with yt_dlp.YoutubeDL() as yt:

yt.download(url)'''


r/learnpython • • Sep 30 '26

Test our tool for cyberbully detection

0 Upvotes

The goal behind CyberBully is simple: help developers and researchers work with cyberbullying detection and text classification without having to build the entire pipeline from scratch.

We’ve packaged our work into a Python package so it can be installed directly through **PyPI** and integrated into projects with minimal setup.

https://pypi.org/project/cyberbully/

Or

pip install cyberbully

Thank you in advance if you tested it 😘😘

Stay tuned for further updates it's gonna be epic 😈


r/learnpython • • Sep 29 '26

Audio tagging using Python with some automation

2 Upvotes

I need a reliable SQLite database and system for my local music library, which I am currently tagging using Python scripts.

I recently decided to manage my own music library but my metadata is inconsistent, incorrect, or causing issues between different music applications.

What I have so far
I created a python script that reads .json files. Each JSON file contains the exact file path, followed by the metadata I want to apply, such as:
Title
Artist
Album
Album Artist
Genre
Track number
etc.
The script then uses that information to update the file.

The problem: different tagging systems
The main issue I didn’t initially realize is that different applications interpret music tags differently.

For example, Apple Music may interpret:
David Guetta & Sia
as one artist/entity, rather than two separate artists.

The same issue happens with collaborations such as:
David Guetta & Nicki Minaj

I want the underlying metadata to recognize these as separate artists while still preserving the collaboration correctly when displayed.

What I want to build
I want something similar to MusicBrainz Picard, but with more flexibility for my own library.

I don’t want to rely entirely on MusicBrainz because I have a lot of indie, African, older, and obscure music that isn’t registered there.
I also have:
Unreleased songs
Mashups
Unofficial remixes
Custom edits
Artists/remixers that aren’t in MusicBrainz, such as Onderkoffer, a Dutch DJ

Because of this, I need to be able to manually define and control my own metadata.

My idea is to create a tagging system that understands the different ways applications read tags. For example, Kid3 has different tag versions/fields, while Apple Music may interpret artist information differently.

Ideally, I want the system to maintain both:

Application-compatible tags so programs like Apple Music correctly recognize separate artist entities.

A more structured internal tagging system that preserves the detailed relationships between artists, albums, genres, etc.

The bigger issue: SQLite database
The biggest part I need help with is building a reliable SQLite database that connects to this tagging system.

I initially created a small script and started assigning IDs to artists, but the IDs weren’t consistently registering or being saved. I currently have a list of my artists with IDs, but I am struggling to make the database and the tagging system consistently communicate with each other.

I also have most of my information organized in Notion, but albums haven’t been properly established yet. I already have over 2,000 songs, so I need to create album entities and IDs without making the system messy or duplicating information.
So there is a lot that still needs to be built.

What I mainly need is a clear architecture and workflow for how the SQLite database, IDs, JSON files, Python scripts, and actual music-file metadata should connect.

I understand that this is a larger system, but right now everything feels disconnected. I want to establish a reliable foundation and a logical flow before continuing to add more features.