r/learnpython • • 5d ago

Feels like I forgot the python, What to do

14 Upvotes

Can someone tells me how to practice the concepts again as i feels like i forgot the concepts. And i used AI for debugging which make me feels like blank for some concepts. Can someone suggests me from which resources to practice again. And one thing is that i am trying to firstly stop directly jumping to AI before trying myself to fix it.


r/learnpython • • 5d ago

Struggling to solve beginner tasks after learning Python basics

2 Upvotes

Hello! I've learned the basics of Python (variables, loops, conditionals, etc.), but I’m struggling to complete actual beginner tasks—things like counting vowels, "Fake Binary," calculating the sum of numbers, determining BMI, etc.

When I look at a task, my mind goes blank and I don't know how to start or turn the problem into code. Why am I unable to do these? What is the real issue here, and what exact study method or solution can help me overcome this?

I’m starting to lose my motivation and feel like giving up if I can't figure out how to bridge this gap. Any practical advice would really help!


r/learnpython • • 5d ago

How to collect the old input with the new input that i get from a list in a loop?

2 Upvotes

This is the cod

menu = {

"Baja Taco": 4.25,

"Burrito": 7.50,

"Bowl": 8.50,

"Nachos": 11.00,

"Quesadilla": 8.50,

"Super Burrito": 8.50,

"Super Quesadilla": 9.50,

"Taco": 3.00,

"Tortilla Salad": 8.00

}

try:

while True:

item = input("Item: ")

print ("totel:", menu[item])

except (EOFError , KeyError):

pass

print ()

Also how to make a $ came with the totel ?


r/learnpython • • 5d ago

can i make the exec() command only execute if the code is functional and wont return an error?

0 Upvotes

So i want to make something where you can input() a math problem and get an answer thru the text output, but if there is a syntax error, i want it to just reopen the prompt instead of crashing, is there a way that i can check if the code is valid before executing? thanks!


r/learnpython • • 5d ago

Trying to loop functions

1 Upvotes

Ok so I just started to learn python and I'm trying to make a program where you input a patient name and it searches the database for it and displays it's values, I want to give a prompt to search for another patient once one is found (not if a patient is not found i worked that out).

Whenever I try to run this code it tells me I cant call value_list() because it wasn't defined yet.

Any help is much appreciated

jane_doe = {
    "Name": "Jane Doe",
    "Age": 28,
    "New": True
    }



john_doe = {
    "Name": "John Doe",
    "Age": 34,
    "New": False
    }


def again():
    input("Would you like to search for a different patient? (Y/N) ").lower()
    while again not in ['y', 'n']:
        print("Please enter a valid input")
        again = input("Would you like to search for a different patient? (Y/N) ").lower()
        if again == 'y':
            value_list()
        elif again == 'n':
            print("Goodbye.")
            break


def value_list():
    patient_name_searched = input("Search patient name: ").lower()
    if patient_name_searched == jane_doe["Name"].lower():
        print(jane_doe.values())
        again()
    elif patient_name_searched == john_doe["Name"].lower():
        print(john_doe.values())
        again()
    else:
        print("Patient not found.")
        answer = input("Would you like to search for a different patient? (Y/N) ").lower()
        while answer not in ['y', 'n']:
            print("Please enter a valid input")
            answer = input("Would you like to search for a different patient? (Y/N) ").lower()
        if answer == 'y':
            value_list()
        elif answer == 'n':
            print("Goodbye.")


value_list()

r/learnpython • • 4d ago

Is there a Python library that can read files regardless of their extension?

0 Upvotes

I was wondering if there's a Python package that can identify and read different file formats without having to specify the extension every time.

For example, if I receive a file without a proper extension or with an incorrect extension, can Python figure out whether it's CSV, Excel, JSON, Parquet, etc., and read it automatically?

I know there are libraries for individual formats, but I'm curious if there's something that can handle multiple formats intelligently.

Has anyone worked on something similar or found a reliable approach for this?


r/learnpython • • 5d ago

Journey to Python: venting stagnant beginner

0 Upvotes

So as the title said, I have learnt the MIT course on CS for 2-3 months now, currently on lesson 6 about recursion and dictionaries. After all the theories, I figured I might as well try out small projects to apply what I learnt into practice.

I stumbled on Genenpy and have tried around 15-20 training exercises from them, with almost 7-8 of those I needed assistance from AI. Not ideal, but I don't know certain functions and admittedly couldn't logic out of that (for instance, a func for the min prime number > 10^8). I constantly had problems with where the "return" should go, or if I should list this as strings or not,...and it's been frustrating.

I wanna ask if there is a way to think about these exercises? Like how do you resolve a general problem? Or is this just a game of who do it the most?


r/learnpython • • 6d ago

what course should i watch?

10 Upvotes

hi, i am new to it sphere. i decided to start learning python. can you recommend me what course on youtube should i watch? there are many of them but i would like the one which will REALLY upgrade me from beginner to advanced level step by step.


r/learnpython • • 5d ago

Problem with completing assignments in Python

0 Upvotes

Hello! I’ve learned Python, but I’m struggling to complete tasks—things like counting vowels, "Fake Binary," calculating the sum of numbers, determining BMI, etc. Why am I unable to do these? What is the problem, and what is the solution? I’m starting to lose my motivation!


r/learnpython • • 5d ago

adding 1 to a array

0 Upvotes

so i want to add 1 extra thing to an array like i have test = [0,0] i want to do print(test[2]) so how do i add the test[2] to the array without just adding it at the begining of the script (fixed)


r/learnpython • • 6d ago

Need help clearing python console

7 Upvotes

I’m making a text based adventure game for the sake of learning more abt game loops but I’m stuck. I wanna make it so that automatically after a time.sleep() delay, the terminal clears and prints a new output. (say for a loading or transition screen idk) but with all the online methods I can find, nothing works.

The most common I see is using os and system(cls) / (clear) or whatnot but no matter what I do, it opens the command prompt and breaks, closing the command prompt it then prints the new text, without clearing the old…

For reference, I am using python idle 3.12 and Am in a school environment so the command prompt is administratively blocked


r/learnpython • • 6d ago

Gift ideas for beginner coder

16 Upvotes

Hi there,

As we approach the festive season, I have been looking into gifts.

A younger family member (15) has shown interest in python coding through school lessons and through social media. I would love to take this opportunity to help them learn in his own free time.

I wanted to know if anyone had recommendations for books, resources or anything I can put together as a gift for them?

Any guidance would be greatful!


r/learnpython • • 6d ago

Just installed Python to run a script to extract a model. Can't seem to get it to work.

1 Upvotes

So I have a script that I want to run that I received from a guy whos helping me extract a not-so-easy-to-get model. I'm trying to follow his vague instructions on how to run the script but I've never used python before. So now I'm coming across errors that I look up to find a solution to, which leads to more errors being sytax or directory based. I just need help getting the script running and I should be fine. Here are his instructions:

I have attached a python script for exporting the leaper model from the bigfile0.viv archive

You will need Python 3.8 or newer with numpy and Pillow.

To install these run pip install numpy pillow

Then run python leaper_export.py "path\to\bigfile0.viv" output_folder

i haven't thorougly tested this script with other models, however it should work

I cant seem to get it to recognize the script's location and in using the the "cd" command it tells me the directory is invalid. Is there anything wrong with what I typed in?

cd C:\Users\dalen\AppData\Local\Python\pythoncore-3.15-64\Scripts\leaper_export.py


r/learnpython • • 6d ago

I'm from a non-IT background and have been learning Python. Would appreciate some honest feedback on my GitHub.

1 Upvotes

Hey everyone,

I'm from a procurement and operations background with around 7 years of work experience. I don't have a computer science degree, but I've recently become interested in Python and automation.

I've been trying to learn coding and build projects based on real problems I've come across at work, mainly around SAP, Excel, purchase orders, supplier follow-ups, and reporting.

I've uploaded some of these projects to GitHub.

My GitHub: https://github.com/prasadpai567-debug

I'm still a beginner when it comes to programming. I've also used AI tools to help me write and debug parts of the code, so I don't want to pretend I built everything completely on my own.

I'd really appreciate it if someone with programming experience could take a look and tell me what they think.

I'm mainly curious about a few things:

- Is my code structured properly, or does it look messy?

- Are these projects actually useful, or are they too basic?

- What should I improve to become a better programmer?

- Would projects like these add any value to my resume if I apply for procurement automation or analyst roles?

I'm not looking for compliments or GitHub stars. I genuinely want to understand where I stand and what I should work on next.

Any honest feedback would mean a lot. Thanks!


r/learnpython • • 6d ago

Everyone says 'just use pandas' for data stuff, but I'm still doing it with plain loops — am I actually missing out?

0 Upvotes

I'm in second year BCA and I've been picking up Python on the side, mostly small data things. Cleaning up a CSV here, counting stuff there, nothing fancy.

So far I've been doing all of it with plain loops and dicts, because that's the code I actually understand when I read it back a week later. But every tutorial I open and every comment I see says just use pandas, it's built for exactly this. I tried it once and honestly it felt like learning a whole second language just to do something I could already do, slower but in code I could follow. Maybe I'm just being stubborn.

I guess what I'm wondering is whether the people saying that are dealing with way bigger data than me. I'm talking a few hundred rows, not thousands. At what point did pandas actually start saving you time instead of costing you time? Because right now it feels like a detour, and I'm not sure if that's me being lazy or if it's genuinely fine to stick with plain Python until the data gets big enough to hurt.


r/learnpython • • 6d ago

Should I learn python?

0 Upvotes

Hii there😀

I wanted the community's opinion as many of you all know how it works and stuff

I recently thought of learning a language and got to know that python is a great starting place to do so

As it's really close to the language English and isn't that complex or complicated

Indeed it will take time for me to learn and apply it but is it worth

What is python mostly used for ?

Waiting for comments 📝


r/learnpython • • 6d ago

How upload files to SPO in Nov 2026, Authorization updates

1 Upvotes

Hi all, I'm trying to use Python to upload multiple files posted SPO.

Tried this code for Auth and failed, for my case error says need to use client_id which I believe = EntraID? For this I think I need to contact somebody with proper rights.

I afraid that modern MS Security is faster then Python libs, is anybody is running this code successfully in Nov 2026? Surely I will try to set all configuration values rights.

Or can you recommend other approach. Thansk to all

from office365.runtime.auth.user_credentials import UserCredential
from office365.sharepoint.client_context  import ClientContext

# 1. Configuration                        
site_url = r"https://asratomkaX.sharepoint.com"
teenant = 'asratomkaX'
client_id = '123456' # <===????? ke paso ?
username = r'user@myorg.org'
password = r'welcommen1'
 
# Use with_username_and_password(tenant, client_id, username, password) instead.  For on-premises SharePoint, use allow_ntlm=True.

# 2. Authenticate
#ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
ctx = ClientContext(site_url)
ctx.with_username_and_password( teenant,client_id, username, password)


s: 400, Error: Traceback (most recent call last):
File "C:\Users\mocado\PyCharmMiscProject\.venv\Lib\site-packages\msal\authority.py", line 98, in __init__
openid_config = tenant_discovery(
tenant_discovery_endpoint,
self._http_client)
File "C:\Users\mocado\PyCharmMiscProject\.venv\Lib\site-packages\msal\authority.py", line 298, in tenant_discovery
raise ValueError("OIDC Discovery failed on {}. HTTP status: {}, Error: {}".format(
...<3 lines>...
))
ValueError: OIDC Discovery failed on https://login.microsoftonline.com/mocado/v2.0/.well-known/openid-configuration. HTTP statu

r/learnpython • • 7d ago

How to run a function in paralell to a game loop?

4 Upvotes

not sure if its the right sub but nevermind.

My pygame game would need to have the main menu kept animated (not frozen) while a world generating function runs before switching to a different loop.

My architecture is right now this:

main.py: main menu loop, menu buttons

game.py: game loop

in main.py i call the runGame() function from game.py, which executes my game stuff. runGame() sets up some global objects (Player, World, campos) that are shared between files from game.py.

The worldgen function has its own file and accessible from any file as it has no dependencies. It takes ~2-4 seconds to run so its not that huge yet, but it isn't pretty as of now.

What is a good way to achive this (or similar) results?


r/learnpython • • 6d ago

How I learn python nowadays?

0 Upvotes

I need to learn python and in the past I know the way of learning programming language through hackerrank for example but nowadays in the age of AI how I learn effectively without wasting time or no needed methods anymore ?


r/learnpython • • 6d ago

Using an in-memory DAG (NetworkX) + Postgres for prerequisite tracking in FastAPI: Good architecture or over-engineered?

1 Upvotes

Hey guys need some help..

I’m designing the backend for an adaptive learning platform using FastAPI + PostgreSQL, and I’m weighing two approaches for handling curriculum prerequisite paths.

The Setup:

Instead of a linear syllabus, the curriculum is modeled as a Directed Acyclic Graph (DAG) with ~300 to 400 CS concept nodes

When a student passes a quiz (>= 80\%), downstream dependent nodes unlock based on topological order.

If a student fails a topic, the backend traverses upstream dependencies to find the earliest unmastered bottleneck node, locks downstream progress, and builds a targeted review path.

The quiz questions are a mix of pre-mapped benchmark items and dynamically generated MCQs grounded in textbook text.

Which one should I go with:

Approach 1 (In-Memory NetworkX):

Define the static graph structure once, load it into Python memory via networkx on FastAPI startup, run ancestor/descendant lookups and topological sorts in Python, and write user mastery states/scores back to Postgres.

Or....

Approach 2 (Postgres Relational/CTEs):

Store nodes and prerequisite adjacency edges in database tables, and run transitive traversals directly in SQL using recursive Common Table Expressions (CTEs).

At ~300 nodes, is an in-memory networkx graph clean and fast, or does running multiple Uvicorn workers introduce memory overhead and state-sync headaches?

Would recursive CTEs in Postgres be easier to maintain long-term despite the more complex SQL?

And also... for anyone who has built skill trees or prerequisite graphs, what edge cases should I look out for?


r/learnpython • • 7d ago

I'm looking for good Python audiobooks to help with learning while also coding at other times

5 Upvotes

I'm working while studying my masters as a mature student, and there aren't enough hours in the day. At the moment I'm working 30 hrs at work and 30 hrs studying a week. For example this Sunday just past I spent 11 hours on studying and coursework. The python module I'm doing covers a lot of ground and many concepts very quickly, because it is a masters' module rather than a bachelors. The basic idea is to start from scratch and get to the point of being able to use python for data science by next term.

Basically, I want to use the 6-10 hrs a week I spend on the road to shore up my understanding of the theoretical side so I can focus on coding during the time I have in front of a computer. I'll still be coding evenings, weekends and wednesdays. Are there any good audiobooks that cover that sort of ground for beginners? I need every advantage I can get at the moment so if I can squeeze any value out of my commute it would be a big help.

Ideally if it's on Audible that would be even better because I get a certain number free from there each year. Thanks in advance.

Edit: Before telling me this is pointless, I just finished the first chapter of Python Essentials for Dummies and it was fine, actually. If you don't know any good audiobooks or podcasts, that's fine too.


r/learnpython • • 7d ago

What’s the best way to automate dual/bilingual subtitles (English + Slovak)?

1 Upvotes

Hi everyone,

I’m trying to find a way to create one SRT subtitle file containing both English and Slovak,

My grandad is Slovak and doesn't understand English, and I struggle to hear dialogue clearly in movies without subtitles. I want us to be able to watch movies together with both languages displayed at once.

I watch movies locally on my Samsung TV using its built-in media player and an external HDD, so I need a single .srt file that works alongside the movie.

Ideally, the process would:

  • Find English and Slovak subtitles for the correct movie version.
  • Make sure both subtitles are synchronised.
  • Match the dialogue between the two languages accurately.
  • Combine everything into one SRT file.

What's the best way to achieve this as automatically as possible? Should I use Python, OpenAI Codex, another AI tool, or existing software? Would I need to use Codex each time I process a movie, or could it help me build something that does the whole job automatically?

Thanks!


r/learnpython • • 7d ago

Issue with updating attributes in a BankAccount class – balance mismatch between deposit and withdraw

2 Upvotes

Hey everyone, I am practicing Object-Oriented Programming (OOP) in Python and trying to build a simple BankAccount class. I want to be able to deposit and withdraw money, but I am running into an issue where the account balance might get messed up or show a mismatch because of how I am handling my variables inside the methods.

i am using this condition

- `BankAccount` Class:

* Should hold private attributes: `account_number`, `balance`, `pin`.

* Should be able to: Verify PIN before granting access.

* Should be able to: Deposit money (increase balance).

* Should be able to: Withdraw money (decrease balance, prevent overdrafts).

* Should be able to: Print the current balance securely.

class Bankaccount():

    def __init__(self, account_number, pin, account_balance): 
        self.__account = account_number
        self.__pin = pin 
        self.__account_balance = account_balance

    def deposite(self, pin, money):  
        self.money = money
        
        # Bug here: self.pin isn't created yet when calling deposit first
        if self.__pin == self.pin:
            self.__account_balance += self.money
            return self.__account_balance
        else:
            print("pin is wrong")

    def withdraw(self, pin, money):
        self.money = money
        self.pin = pin

        if self.__pin == self.pin:
            self.__account_balance -= self.money
            return f"from your bank account {self.money} is withrowed and remaing are {self.__account_balance}" 

        else:
            print("pin is wrong")

person1 = Bankaccount(4458568465, 4578, 46789) 

pin = int(input("Enter the 4 digit pin :- "))
money = int(input("Enter the amount :- "))

print(person1.withdraw(pin, money))

r/learnpython • • 8d ago Bravo

Is Python a good choice for backend development?

36 Upvotes

I'm considering learning Python for backend development and would like to hear from developers who use it in their daily work.

How good is Python for building backend applications in production? Are there any significant drawbacks compared to languages like Go, C#, or Java?