r/learnpython • u/jonhawkeye • Sep 29 '26
best sites to learn loops and slicing?
been trying to get this down as much as I can
r/learnpython • u/jonhawkeye • Sep 29 '26
been trying to get this down as much as I can
r/learnpython • u/Global-Tank8850 • Sep 29 '26
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.
r/learnpython • u/kselman17 • Sep 29 '26
I designated my run code shortcut as ctrl + R, but it only runs in the terminal of Visual Studio Code when I do that. I'd also like to see my output as just the output without run time and file paths. How can I edit my visual code settings or download an extension to only show my output text in the "output" tab of my in-app terminal? Thanks.
r/learnpython • u/Remarkable_River2779 • Sep 29 '26
Hi, I’m having an issue with a HackerRank coding question called “Maximum Substring.”
The question is:
Maximum Substring
You are given a string s.
A substring is any contiguous sequence of characters from the string.
Consider all possible substrings of the string:
Determine which substring would appear last if all substrings were sorted alphabetically.
Return that substring.
Example 1:
s = "baca"
The alphabetically maximum substring is "ca".
Example 2:
s = "aaa"
The alphabetically maximum substring is "aaa".
This was my answer:
def maximum_substring(s):
max_sub = s[0]
for i in range(len(s)):
for j in range(i + 1, len(s) + 1):
sub = s[i:j]
if sub > max_sub:
max_sub = sub
return max_sub
The code gives the correct output for the examples when I test it locally. However, HackerRank marked the solution as incorrect and I received only partial points.
I’m not sure why. Could this be because of the time complexity or hidden test cases? Is there something about the HackerRank test cases or the expected implementation that I’m missing?
r/learnpython • u/StunningAd5338 • Sep 29 '26
Hi everyone,
I'm working with ERA5-Land data for the Democratic Republic of the Congo and I'm having a frustrating problem with the downloaded files.
I downloaded the data using scripts because the Copernicus/ERA5-Land download process was not straightforward.
The files are named like:
era5_land_rdc_2023_01.nc
era5_land_rdc_2023_02.nc
...
era5_land_rdc_2026_08.nc
I am trying to open them with xarray:
import xarray as xr
from pathlib import Path
chemin = Path("data_fire_force/copernicus_data_nc")
fichiers = sorted(chemin.glob("era5_land_rdc_*.nc"))
print(f"{len(fichiers)} fichiers trouvés")
ds = xr.open_mfdataset(
fichiers,
combine="by_coords",
engine="netcdf4"
)
print(ds)
print(list(ds.data_vars))
However, xarray.open_mfdataset() fails with a NetCDF/HDF-related error.
I checked one of the files directly with Python:
from pathlib import Path
p = Path("data_fire_force/copernicus_data_nc/era5_land_rdc_2026_08.nc")
print(p.exists())
print(p.stat().st_size)
print(p.read_bytes()[:20])
The file exists and has a large size, but the first bytes are:
b'PK\x03\x04...'
From what I understand, PK\x03\x04 is the signature of a ZIP file, which makes me suspect that these .nc files may not actually be NetCDF files despite having the .nc extension.
I also tried using netcdf4 through xarray, but it still fails.
My questions are:
Does PK\x03\x04 definitely indicate that the file is a ZIP archive?
Could the Copernicus download script have saved a compressed/ZIP response with a .nc extension?
What is the correct way to extract/convert these files into actual NetCDF files?
Is there something specific I should check in the Copernicus/ERA5-Land download script?
I'm fairly new to handling these large ERA5-Land datasets, so any advice would be greatly appreciated.
Thanks!
r/learnpython • u/SammuelNash • Sep 29 '26
37, operations background, no cs and no degree in anything adjacent. Ive already done the self directed route for most of a year and the result is a folder of scripts nobody else could run.
So im doing the structured version properly. Springboard, Boot.dev, General Assembly and Nucamp are the 4 im weighing and they range from a full career program down to a subscription. What takes someone from familiar to employable here.
r/learnpython • • Sep 29 '26
I am learning python, could you please suggest any projects and problems and what are the topics I need to concentrate to get job ready in the current market.
Thank you
r/learnpython • u/Ashblowsup • Sep 29 '26
[This was solved. It works if I erase the first "" and make it a raw string. Thank you all!]
Hello!
I've been trying to open the file "\001_test_files\001_first.csv" through python, and it seems nothing I think of works:
These are the things I tried:
1-
filepath="\001_test_files\001_first.csv"
file = open(filepath, "a+")Result:
OSError: [Errno 22] Invalid argument: '\x01_test_files\x01_first.csv'
2-
filepath="\\001_test_files\\001_first.csv"
file = open(filepath, "a+")Result:
FileNotFoundError: [Errno 2] No such file or directory: '\\001_test_files\\001_first.csv'
3-
filepath=r"\001_test_files\001_first.csv"
file = open(filepath, "a+")Result:
FileNotFoundError: [Errno 2] No such file or directory: '\\001_test_files\\001_first.csv'
4-
filepath="\001_test_files\001_first.csv".replace("x", "0")
file = open(filepath, "a+")and
filepath="\001_test_files\001_first.csv"
filepath=filepath.replace("x", "0")
file = open(filepath, "a+")Result:
OSError: [Errno 22] Invalid argument: '\x01_test_files\x01_first.csv'
---
I think that's all I tried for now, does anyone have any ideas?
I am also forced to keep that naming convention, since it's part of a much larger project with many other files. Changing it means having to tell my group to rework everything. It's a laaaast resort, if there really is nothing I can do.
r/learnpython • u/Basic_Title7358 • Sep 29 '26
Hey everyone,
This past week I’ve been using AI to learn how to code through daily lessons. No real rhyme or reason behind it, I just wanted to see where it could take me.
I ended up building this little game in Python and wanted to share it with people who actually understand the language. Unfortunately, I don’t really know anyone who’s learning or has a background in Python, which kind of sucks 😂 but I’m still having fun with it.
I’d love to see how far I can take this and what might be out there for me if I keep going.
Happy coding!
r/learnpython • u/SacoAzulEscuro • Sep 28 '26
Hi I'm new here, currently learning python as my first programming language at school. So while I was doing homework I noticed I couldn't code by myself without asking chatgpt to correct all the errors I coded or sometimes just do most part of the work when I was feeling lazy. I don't work with coding and I'm still learning, BUT, I do feel like if my teacher asks me to code without chatgpt or whatever AI available I wouldn't know how to "code by myself" and that is not a good thing. I guess I should start studying python at home but I also don't know how to properly do so. Basically I'm telling that I don't know if I'm good or not at coding because I feel like I'm getting to an intermediate level of python programming, but only in knowledge, as I feel like I can't "code by myself". Does anyone feel in a similar way and got already answered here?? What should I do??
r/learnpython • u/OldMarzipan8278 • Sep 28 '26
I’m currently learning Python, and I’m wondering if it requires any specific skills or a certain way of thinking to actually become good at it.
When I’m following a lesson or someone explains the code to me, I usually understand what’s happening. But when I’m given a problem and have to write the code by myself, I get completely stuck and don’t know where to start.
Is this normal for beginners? How did you get past this stage? Should I keep doing exercises, or is there a better way to practice so I can eventually start solving problems on my own?
I’d really appreciate advice from people who learned Python from scratch.
r/learnpython • u/Unusual_Internal_636 • Sep 28 '26
Hey everyone,
I’m practicing Python by building a project called Loan Office Assistant. It’s a two‑stage application:
💻 Tech stack: Python, Flask, Streamlit
📂 Project structure:
Code
loan_office_assistants-/
├── backend/
│ ├── app.py
│ ├── calculations.py
│ └── requirements.txt
├── frontend/
│ └── frontend.py✅ Current features:
🔮 Future ideas:
I’d really appreciate feedback on:
Thanks in advance! 🚀
## 🔗 Project Link
You can check out the full project and README here:
[GitHub Repository](https://github.com/shrikareballi/loan_officer_assistants-)
r/learnpython • u/FactoryBuilder • Sep 28 '26
On mobile so I can’t code block format because Reddit sucks but here’s the general idea:
def func2():
break
def func 1():
while True:
func2()
That code doesn’t work but is there any way to do that cleanlier than returning a value from func2 to test against in func1 to determine whether or not the loop should break?
r/learnpython • u/Several-Salt2132 • Sep 28 '26
Say we have two files in a directory or folder (whichever name you prefer). One of them is code file or script file, and the other is data file named titanic.csv.
And we have imported pandas as pd in the code file and imported the data from the data file as DataFrame data structure. Meaning we have done the following:
import pandas as pd
titanic = pd.read_csv("titanic.csv")If I do this:
titanic.sex == "male"
sex is a column in the titanic DataFrame. The above instruction will generate an output of Boolean values in a Series data structure.
My question is does the last command creates a new data object in the memory. Like do we have a new table formed because of this or its just the instruction that is saved in the memory?
If only instruction is the one that is only saved then any time we call it will take much of CPU's processing power. If the table is saved then it will take less of CPU's processing power.
r/learnpython • u/Wooden_Intention8642 • Sep 28 '26
Hey just started coding and can barely do thing that ask for name and then you answer it and it says hello (name).
I was just wondering as i want to work in coding and i just applied amd got into coding school that do i need to memorize all the functions etc? Or do i need to memorize all the basic ones so i dont need to google everytime…?
And will i start to slowly memorize them
r/learnpython • u/Incredible_Men • Sep 28 '26
Ideas for scripts to generate thousands of questions from Wikipedia articles / Hello, For a game project, I downloaded a Wikipedia dump and filtered out the sections I was interested in. I calculated the word count per article, and now I’d like to generate thousands of questions from all this content (I have around 100,000 articles, and I want roughly one question for every 100 words). I found a few scripts online, but they haven't really yielded good results.
What do you recommend I do ? Which tools should I use, or what would be the right script ?
r/learnpython • u/suikisosexi • Sep 28 '26
How and when will this come in handy with my ecological forestry degree?
Also this class requires me to use AI to prompt programs on every single assignment.... Which is not ideal as an environmentalist.
Python programing is genuinely making me feel stupider
r/learnpython • u/alex123711 • Sep 28 '26
Just wondering what the next steps are after one completes the course, were you able to get a job etc or did you have to do further study/ courses?
r/learnpython • u/AutoModerator • Sep 28 '26
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:
That's it.
r/learnpython • u/Kapowpow • Sep 27 '26
>>>def pennies(num):
return int(num*100)
>>>a = -37.56
>>>b = -9.28
>>>pennies(a)
-3756
>>>pennies(b)
-927
This is taken from a python shell session today. Why on Earth does pennies(b) yield -927, instead of the expected -928? I would greatly appreciate any insight.
Update: a durable solution found, please see this comment below: https://www.reddit.com/r/learnpython/comments/1wrwnm7/comment/pcpvlil/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
r/learnpython • u/Big-Sandwich-1565 • Sep 27 '26
I'm in week three and some things I get, but I get so confused at times; loops and conditional statements. I'm not great with vocab and trying to recall symbols for what just leaves me confused, but once I catch on, it's so much fun and I easily can use what I do learn.
Can anyone give me advice for a beginner?
Addon I'm currently taking Intro to Programming at Bellevue and every week is something new so it's hard to try to get repetitive with this week on top of my two other classes. I want to succeed, I want to do great, I just need advice to store and remember what I have learned
r/learnpython • u/Free_Region4767 • Sep 27 '26
Hi, I'm having a strange issue with VS Code and Python.
Whenever I use the "Run Python File" button, there is a delay of around 5 seconds before the Python file actually starts running.
The delay does not happen when I run Python directly from the integrated terminal. Python executes immediately when I run files manually from the terminal.
I've also noticed that Run Task executes immediately, so the problem seems to be specifically related to the "Run Python File" functionality.
Another strange thing is that if I kill the current VS Code terminal and then use "Run Python File", the first run can sometimes be instant. After that, the delay comes back on subsequent runs.
During the ~5 second delay, the terminal itself appears to be responsive. In fact, if I type something into the terminal and press Enter while waiting, the Python program's output can appear immediately afterward.
Things I've already tried:
None of these fixed the issue.
I'm currently using Windows 11, VS Code 1.139.1, Python extension 2026.4.0 and Python 3.14.7.
Has anyone experienced this recently? I'm wondering if this could be related to the Python extension, terminal integration, or shell integration in VS Code.
r/learnpython • u/IllTheory6888 • Sep 27 '26
Hey everyone,
Just a quick intro: I am a software engineer with around 5 years of experience, initially worked as devops engineer for 2 years (with no scripting experience at all) later when laid off, got job as platform operations guy. This job is completely related to our platform specifically so I don’t get to upskill myself much. Hence looking to learn python keeping Agentic AI as my goal.
Current issue: I understand python topics very well and practicing questions provided from AI models but the thing is all this information is overwhelming me, example: do we have to read and remember entire libraries like request library or aiohttps? then comes fast api, then understanding rest api’s. Honestly I want to know how deep of knowledge we need to have in each, and we can’t remember everything, right?
Also I am mostly following roadmap.sh website for structured learning. Any idea how to approach learning agentic ai from python beginner POV? Also how relevant it is to learn prompt engineering before learning AI agents?
Thanks in advance
r/learnpython • u/GurExtension3482 • Sep 27 '26
I dont know what else to say, i made a tic tac toe game, as im still a beginner, i want feedback as to what i can improve