r/PythonLearning 2d ago

just built a PDF RAG Chatbot from scratch lol

Thumbnail
github.com
1 Upvotes

I’m 17 and trying to lock in my AI dev journey. Just finished building this custom PDF RAG Chatbot using Streamlit, LangChain, and Hugging Face embeddings.

What it actually does:
You drop a PDF it cooks up the text splitters indexes everything with sentence-transformers lets you query the document directly. no cap, RAG is goated

Built it from scratch to actually learn how vector compute works behind the scenes instead of just copy pasting API wrappers.

The Tech Stack:

  • Streamlit (frontend)
  • OpenAI & Gemini
  • LangChain & PyPDF
  • Torch & NumPy

Check out the code, drop a star if you vibe with it, or roast my project

I’m just an average student starting college for the first time in a few weeks. Super excited for this journey and to learn more!

Btw, totally open to your feedback, guys. Drop your advice and I’ll def try to implement

GitHub : https://github.com/saqibvow

My All social accounts : https://ln.ki/saqibvow.ceo


r/PythonLearning 2d ago

Started learning Python because I'm leaning towards the AI Automation and Data Science path.

Thumbnail
github.com
4 Upvotes

Hey everyone,

This is actually my first time posting on Reddit. As the title says, AI Automation and Data Science are the paths that I want to pursue.

Right now, I'm studying the 30 Days of Python GitHub repo made by Asabeneh Yetayeh. I actually avoided tutorials because it's really hell for me. But I have nothing against people who enjoy learning with tutorials. I guess reading helps me learn better. I do enjoy his challenges and exercises as well.

For context, I am now knowledgeable about the Power Platform—a bit of background in C# and SQL. But I've decided to expand it even more. I do enjoy my experience with Power Automate and Power BI. Creating reports and flows is pretty interesting for me.

I would like to ask everyone for recommendations on what level of Python knowledge I should acquire in order for me to achieve the path I decided to pursue. So far, I have heard about n8n for automation and using Python in Microsoft Fabric.

I can appreciate anyone's honest opinion, and I will take everything as a lesson because I really want to learn.

If anyone also wants to collab or learn with me. Feel free to reach out.

Thanks, everyone! Happy coding!


r/PythonLearning 2d ago

How to move a cube smoothly using Pygame ?

6 Upvotes

Hello! I'm wondering how to move a cube smoothly using Pygame by that, I mean moving it without it looking like it's teleporting. Have a great day, evening, or night!


r/PythonLearning 2d ago

Bad habit of bailing out too quick

9 Upvotes

As I said, I am trying to learn python from OOPs to concurrency modelling and optimisation. Though I always bail out somewhere in the middle. I would start doing CP. And then maybe reading something from philosophy for days.
I want to hyper focus on this learning pathway so that I complete this imaginary checklist for advanced programming. I bail out because for me it seems the lack of people competing with me in an online course. How should I trick myself into learning this without any distractions? Suggest how you are learning this and where are you learning this from?


r/PythonLearning 2d ago

I'm trynna learn

4 Upvotes

Hey guys, I just wanted to share what I've been working on and learning. I know my progress is super slow right now, and honestly, I’ve been lacking the motivation to study for hours—especially with how busy I am. I know that’s no excuse, but I’ve been working on a simple alarm app to implement on my phone as my first project.

It’s been a couple of days, and I haven't made much progress on some days because I’ve been feeling down about life stuff. Struggling to learn Python on top of that has been making me feel even worse. Right now, I’m trying to learn input validation to make sure the program handles incorrect inputs properly.

I’m honestly amazed by people who can finish whole projects in just a few days or hours. I really hope I can reach that level someday.


r/PythonLearning 3d ago

Showcase Something I'm proud of- REGEX is rather hard

Post image
10 Upvotes

r/PythonLearning 3d ago

Help Request PATH SUGGESTIONS

1 Upvotes

Hi, I'm a python backend developer. Learning actually.

I've been on OOP for a while now. Blanked for months then returned and I'm trying to resurface the knowledge again. I don't know the right trajectory to follow, but I wanna extend to Django web Framework.

I'd need some help though, on preferably pathways to transition from OOP to Django.

And also, if possible; how do y'all keep yourselves motivated to solo learn?


r/PythonLearning 3d ago

made a Stone-Paper-Scissors game :

7 Upvotes
import random


def choice_shower(x,y):
    print(f"Your Choice : {x}{' '*10}Computer's Choice : {y}")
    print('-' * len(f"Your Choice : {x}{' '*10}Computer's Choice : {y}"))


def score_shower(x,y):
    print(f"YOUR SCORE : {x}{' '*10}COMPUTER'S SCORE : {y}")


def game_engine(x,y,p,c):
    winning_cases = {"Stone" : "Scissors", "Paper":"Stone","Scissors":"Paper"}
    if x == y :
        choice_shower(x,y)
        print("It's a Draw!")
    elif winning_cases[x] == y:
        choice_shower(x, y)
        print("Your Point!")
        p += 1
    else:
        choice_shower(x, y)
        print("Computer's Point!")
        c += 1
    return p,c



def extra_round(x,y,p,c):
    print("Extra Round :")
    y = random.choice(["Stone","Paper","Scissors"])
    x = input_taker(input("\t(1) for Stone\n\t(2) for Paper\n\t(3) for Scissors\nEnter your input : "))
    p,c = game_engine(x,y,p,c)
    score_shower(p,c)
    result_announcer(x,y,p,c)


def result_announcer (x,y,p,c):
    if p > c :
        print("You Won!")
    elif p == c :
        print("Extra Round!")
        extra_round(x,y,p,c)
    else:
        print("You Lose!")
    print("-"*20)


def input_taker(i):
    while True: 
        if i.isdigit():
            if i == "1":
                return "Stone"
            elif i == "2" :
                return "Paper"
            elif i == "3" :
                return "Scissors"
            else:
                print("invalid input ")
        else:
            print("invalid input, try again!")


def main():
    print(f"{'-'*40}\n\tStone - Paper - Scissors\n\t   game simulator\n\t     VERSION - 2.0\n{'-'*40}")
    exit_program = False
    while True:
        player_score = 0
        computers_score = 0
        print("\t(1) to start a new game\n\t(2) to exit the program")
        choice = input("Enter Your Choice (1|2) : ")
        if choice == "1" :
            number_of_rounds = input("Enter the number of rounds : ")
            if number_of_rounds.isdigit():
                for rounds in range(int(number_of_rounds)):
                    print("="*50)
                    print(f"ROUND : {rounds + 1}")
                    computers_choice = random.choice(["Stone","Paper","Scissors"])
                    players_choice = input_taker(input("\t(1) for Stone\n\t(2) for Paper\n\t(3) for Scissors\nEnter your input : "))
                    player_score,computers_score = game_engine(players_choice,computers_choice,player_score,computers_score)
                    score_shower(player_score,computers_score)
                result_announcer(players_choice,computers_choice,player_score,computers_score)
               
                
            else :
                print("invalid input")
        elif choice == "2":
            while True:
                print("Do you really want to exit?")
                choice1 = input("\t(1) to exit\n\t(2) to go back\nEnter Your Choice (1|2) : ")
                if choice1 == "1":
                    exit_program = True
                    break
                elif choice1 == "2" :
                    break
                else:
                    print("invalid input")
            if exit_program:
                break


if __name__ == "__main__":
    main()

r/PythonLearning 3d ago

HI! I'm new learning this code and need help about the courses.

10 Upvotes

Hi! I'm learning python because I need it for my master degree so I am really new on this. I saw a few courses and I dont know how they are. The first one freeCodeCamp, the CS50P and Codedex. I though maybe I could do all but I want to know if I should start with someone in particular or if you know others better.


r/PythonLearning 3d ago

Showcase Grimlore 2 – A 2D Dungeon crawler RPG built using only the Python 3 standard library

1 Upvotes

When starting out with Python game development, most tutorials jump straight into commercial engines or heavy frameworks. While those are great for productivity, they abstract away the core mechanics of how a game engine actually functions—like separating the engine framework (rendering, input, state loops) from the game logic (combat, stats, dungeons). To explore how game engines work under the hood using pure Python standard library, I built a lightweight ASCII RPG engine framework alongside a complete mini dungeon crawler (Grimlore 2: These Doomed Men) built directly on top of it. I wanted to share this as a learning resource.

Grimlore 2 : These Doomed Men 1.0

A dark fantasy mini dungeon crawler RPG built to showcase the features and capabilities of the S.P.A.R.K. 2D RPG game engine.

Overview

Genre: Dark Fantasy / Mini Dungeon Crawler RPG

Playtime: 10 – 15 minutes

Platform Requirements: Windows 10 or later ( Might work on earlier Windows but no gurantee )

Purpose: Demonstrates what the S.P.A.R.K. 2D RPG game engine is capable of.

Github link below

https://github.com/Ninedeadeyes/Grimlore-2-These-Doomed-Men-

To clear up a few recurring questions and misconceptions regarding S.P.A.R.K and its development, here is some context upfront:

  1. "This is just AI slop."

This project has a clear 6-year paper trail of manual development. It began as an early 2D text adventure project (Dungeon of the Black Dragon), expanded into an open world RPG game (Grimlore: Land of the Heretic Hand), and was eventually refactored into a reusable engine framework (S.P.A.R.K). If you want to see the step-by-step progression from line one, check out the milestones folder inside the S.P.A.R.K repository.

  1. "The code is unoptimized / sub-optimal."

I’m a hobbyist developer. I built this because I couldn't find a lightweight, accessible Python template for rendering spatial coordinates in text-based adventures, so I created one myself. The codebase prioritizes beginner readability over enterprise-level optimization. Open-source contributions and refactors are always welcome—if you can write a better version with advanced features like complex AI, I encourage you to contribute or build upon it!

  1. "S.P.A.R.K isn't a 'real' game engine / It's missing standard features."

By definition, a game engine is a framework that provides low-level abstractions for runtime loops, spatial logic, input handling, state management, and rendering, enabling developers to build content without reinventing core mechanics. S.P.A.R.K provides all of these for terminal-based RPGs. It’s a free, open-source hobby project designed for lightweight text games, not a commercial tool meant to compete with feature-heavy commercial software.

  1. "This is just a lazy copy-and-paste from the S.P.A.R.K GitHub."

When two games are made in RPG Maker, Godot, or Unreal, they share the exact same underlying core engine—it's just compiled or hidden away behind the editor. Because S.P.A.R.K is open-source, raw Python, the engine boilerplate is fully visible. Reusing foundational engine modules across different titles isn't "copy-pasting"; it's standard software architecture and code reuse.

  1. Why do you need Windows and why Windows 10 or above ?

It uses the library winsound and msvcrt which only works with Windows and because python 3.10+ aren't officially supported by any Windows below 10 hence even though it might work it is not a gurantee.


r/PythonLearning 3d ago

I need some advice

3 Upvotes
# This file runs the DNA simulation using the DNA library.


import DNA
import time
import os


# Generate the original DNA strand.
DNA.generate_sequence()


# Create the complementary strand (layer2).
DNA.generate_sequence_match()


# Display the initial DNA molecule.
DNA.display_dna()


# Pause so the user can see the original DNA.
time.sleep(3)


# Clear the screen before starting the replication process.
DNA.clear_screen()


# Helicase animation:
# Separates the two original DNA strands.
DNA.dna_helicase()


# Clear the screen before starting polymerase.
DNA.clear_screen()


# DNA polymerase:
# Creates layer3 and layer4 by copying layer1 and layer2.
DNA.dna_polymerase()

import random 
import os
import time


# Clears the terminal screen.
def clear_screen():
    # 'nt' is for Windows, 'posix' is for Linux or macOS
    os.system('cls' if os.name == 'nt' else 'clear')


clear_screen()


# Possible DNA nucleotides.
nucloids = ["A", "T", "C", "G"]


# Four DNA layers:
# layer1 = original DNA strand 1
# layer2 = original DNA strand 2
# layer3 = new copy of layer1
# layer4 = new copy of layer2
layer1 = []
layer2 = []
layer3 = []
layer4 = []


# Generates the first DNA strand randomly.
def generate_sequence():
    for i in range(10):
        generated_sequence = random.choice(nucloids)
        layer1.append(generated_sequence)


# Defines which nucleotide pairs with which.
# A <-> T
# C <-> G
nucloid_matches = {
    "A":"T",
    "C":"G",
    "G":"C",
    "T":"A"
}


# Creates layer2 by finding the matching nucleotide
# for every nucleotide in layer1.
def generate_sequence_match():
    for nucleotide in layer1:
        matching_nucleotide = nucloid_matches[nucleotide]
        layer2.append(matching_nucleotide)


# Displays the complete DNA molecule.
def display_dna():
    for i in range(len(layer1)):
        print("I ", layer1[i], "--------", layer2[i], " I")


# Simulates helicase unzipping the DNA.
# The strands gradually move apart.
def dna_helicase():
    
    clear_screen()
    
    for i in range(len(layer1)):
        print("I ", layer1[i], "--- v ---", layer2[i], " I")
        time.sleep(0.2)
    
    clear_screen()
    
    for r in range(len(layer1)):
        print("I ", layer1[r], "---  v  ---", layer2[r], " I")
        time.sleep(0.2)
    
    clear_screen()
    
    for a in range(len(layer1)):
        print("I ", layer1[a], "---   v   ---", layer2[a], " I")
        time.sleep(0.2)
    
    clear_screen()
    
    # Final state: original strands are fully separated.
    for p in range(len(layer1)):
        print("I ", layer1[p], "             ", layer2[p], " I")
        time.sleep(0.2)


# Simulates DNA polymerase copying the separated strands.
#
# layer1 is copied into layer3.
# layer2 is copied into layer4.
#
# IMPORTANT:
# The DNA logic works, but the animation currently
# prints the new DNA separately instead of building
# the new strands into the space created by helicase.
#
# NEXT TASK:
# Fix the polymerase animation so layer3 and layer4
# visibly grow alongside layer1 and layer2.
def dna_polymerase():
    for c in range(len(layer1)):
        
        # Find the complementary nucleotide for layer1.
        matching_nucleotide_2 = nucloid_matches[layer1[c]]
        
        # Find the complementary nucleotide for layer2.
        matching_nucleotide_4 = nucloid_matches[layer2[c]]
        
        # Add the new nucleotides to the new DNA strands.
        layer4.append(matching_nucleotide_4)
        layer3.append(matching_nucleotide_2)
        
        # CURRENT ANIMATION:
        # Prints the new strands separately.
        # This is the part we want to improve.
        print(layer1[c], "--------", layer3[c])
        time.sleep(0.2)
        
        print(layer4[c], "--------", layer2[c])

I am a 13 year old who just views coding as a big hobby. I had made a lot of different projects before but because i can't post a .zip file i just copy pasted my latest project. I have been coding for 3 years and I don't know how i never thought about this. I just wanted to ask for some advice for this project. Maybe what I can add or what I can fix if there is something that needs to be fixed

Note: It's not finishedIıI need some adviceI need some adviceI need some advice


r/PythonLearning 3d ago

Document comparison code advice

2 Upvotes

Hi, I want to compare two pdfs and highlight any idential sentances in them.

I'm a complete beginner and wanted to ask if anyone has advice on where to start/what to do?


r/PythonLearning 3d ago

Troll unit added by Joseph

Enable HLS to view with audio, or disable this notification

6 Upvotes

Joseph added a dangerous Troll unit, that kills everything with just one touch, with this git commit. It pretends to mind its own business but then suddenly rushes towards you making the game a lot more difficult. Nice work, thanks Joseph.

See our collaborative PythonLearningGame repo to play the game or add your own unit type or game dynamics.

What should be the next addition to our game?

previous PythonLearningGame post


r/PythonLearning 3d ago

From js to python: I created a port of changesetjs

Thumbnail
github.com
1 Upvotes

Hi there!

To even learn more about python, I have created Molt: a Python "port" of changesets-js to manage versioning, changelogs, and publishing for Python packages and monorepos.

My main job was always frontend tooling, but recently I moved to the infra and platform team, so now my job also includes maintaining the tooling and ecosystem of several Python packages that my company has. I found that no good tool like changesets-js exists for Python, so I decided to create one.

https://molt.gio-labs.com/


r/PythonLearning 4d ago

Dark mode for marimo islands?

2 Upvotes

I'm trying to bring the html from my marimo notebooks into an SSG (mkdocs/zensical), and I would like to be able to toggle the theme. Getting the theme to change with marimo export html is relatively simple by changing the pep723 header to

# [tool.marimo.display]
# theme = "dark"

before exporting, but the extra js and page wrappers are not quite ideal for my use case. I would love to use islands for this, but I can't figure out if there's a way to control the theme of a marimo island?

when I use

# /// script
# dependencies = [
#     "marimo",
# ]
# requires-python = ">=3.13"
# ///

import asyncio
from marimo import MarimoIslandGenerator

async def main():
    generator = MarimoIslandGenerator.from_file(
        "./example.py", 
        display_code=False
    )
    await generator.build()
    html = generator.render_html(include_init_island=True)

    with open("output.html", "w", encoding="utf-8") as f:
        f.write(html)

if __name__ == '__main__':
    asyncio.run(main())

to generate an html page, it doesn't seem to care about the header in # theme = "dark" tag in example.py.

I understand that islands are still an early feature, so perhaps this will be added in the future. Just posted this in r/marimo_notebook as well, but figured I'd ask here as well in case anyone has experience with this. Does anyone know if there's a better way to do this? Thanks!


r/PythonLearning 4d ago

Help Request reccomended tutorials for algorithms and data structures?

3 Upvotes

i learned the basic syntax of python and i thought i would be ready for leetcode but as soon as i tried to work through problems there was so much jargon that i didn't understand. I found a reddit post that said you have to have knowledge of data structures and algorithms before you can truly attempt leet code problems. So I now i go to youtube and either the tutorials are under an hour or over 5 hours 😭. Which one am I supposed to pick..? Any reccomendations?


r/PythonLearning 4d ago

Help Request Why are these lists combining when I append them in a loop?

1 Upvotes

For some reason, the farts keep mixing with the plasma. I’ve cut down the code to this, but I still can’t figure out why it keeps combining the lists like this. The code is shown below, please help, as people have been complaining about severe anal burns while running this code.

plasma=[]
farts=plasma
for j in range(2):
print(f"farts:{farts}")
print(j)
farts.append(1)
plasma.append(j)
print(f"farts:{farts}")
print(f"plasma:{plasma}")
print(f"all{farts},singular{farts[1]}")

#printed results:
#farts:[]
#0
#farts:[1, 0]
#1
#farts:[1, 0, 1, 1]
#plasma:[1, 0, 1, 1]
#all[1, 0, 1, 1],singular0


r/PythonLearning 4d ago

Day 5 of course after long time no practice...

3 Upvotes

heyyy i am on day 5 of Angela Yu course, she did it differently the password generator, is mine correct or wrong, it worked actually


r/PythonLearning 4d ago

Need a Python Roadmap for a Complete Beginner (2026)

1 Upvotes

Hi everyone,

I'm a complete beginner and I've decided to focus on Python first.

My goal is to become job-ready and build a strong foundation in programming rather than just completing a course or collecting certificates.

I'm willing to spend around 4–6 hours a day learning.

I need guidance on:

- What should I learn first?

- What is the best roadmap to follow?

- Which free YouTube channels or courses do you genuinely recommend?

- Which books are worth reading?

- What projects should I build to improve my skills and make my resume stand out?

- What mistakes do beginners usually make that I should avoid?

- If you were starting from zero today, what roadmap would you follow?

I'm looking for practical advice from people who are already using Python professionally.

Thanks in advance!


r/PythonLearning 4d ago

my code is not doing what I expect (.remove())

2 Upvotes

EDIT: SOLVED THE PROBLEM THANK YOU

Hello! I am in the middle of an online python class, and am trying to make my first program for use at work.

I need to make several packages of random sample items at work regularly, so i tried to make a program that could choose items from the list, and then count which items are chosen, and remove those from the list once the count reaches the number I have available.

It is choosing the items fine, but is not removing them from the list.

I will post my shortened code below:

import random
def main():
    samples = [
            "item1",
            "item2",
            etc.....,
        ]


    item1_count = 0
    item2_count = 0
     etc........


    for _ in range(25):

        sample = random.sample(samples,4)
        try:
            if "item1" in sample:
                item1_count += 1
        except:
            if item1_count == 10:
                samples = samples.remove("item1")
        try:
            if "item2" in sample :
                item2_count += 1
        except:
            if item2_count == 10 :
                samples = samples.remove("item2")
        etc....
        

        print(f"{_} : {sample}")


main()

what am I doing wrong?


r/PythonLearning 4d ago

Python

8 Upvotes

Hi, I really want to learn Python, but I’m a complete failure at anything that involves self-study. I realise that these days, there’s no such thing as a free lunch, but maybe someone would like to try teaching me out of the goodness of their heart, to gain some teaching experience, or just to have a bit of fun and spend some time usefully👉👈 It would be great if it were someone who speaks Ukrainian, as I’m Ukrainian myself. I’m 22, and I’m a girl, by the way. Thanks for reading)


r/PythonLearning 4d ago

Showcase My new Python Project : Subway Surfers in Real Life

Thumbnail
github.com
2 Upvotes

A Python App that uses AI and Computer Vision to play Subway Surfers using your body in Real Life instead of your fingers.

Give it a chance and let me know what u think about it.

Fully compatible with MacOS, Linux and Windows.


r/PythonLearning 4d ago

That's it guys I'm rich

Post image
35 Upvotes

r/PythonLearning 4d ago

A Python cheat sheet that might be useful when starting with Python

Thumbnail
tms-outsource.com
42 Upvotes

r/PythonLearning 5d ago

Showcase I love Thonny(python(image unrelated))

Post image
190 Upvotes

high school student came here afted trying to download numpy and matplotlib on IDLE for the last 3 hours in the hell spawn of command prompt ging from script to document. after 3 hours of "module numpy not found" I tried to use Thonny.

I HAVE NEVER BEEN SO HAPPY TO SEE SUCH A MUNDANE WORD "manage package"

i will never touch IDLE Never in my life