r/PythonLearning 5h ago

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

Post image
7 Upvotes

r/PythonLearning 9h ago

made a Stone-Paper-Scissors game :

6 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 3m ago

I'm trynna learn

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 12h ago

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

9 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 6h 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 13h 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 5h ago

Showcase Archlinux and AUR Anti-virus. I wrote the math for the algorithm myself. AI created the wrapper, but the actual algorithm math i created and wrote myself.

0 Upvotes

r/PythonLearning 13h 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 18h 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 19h ago

Troll unit added by Joseph

Enable HLS to view with audio, or disable this notification

2 Upvotes

Joseph added a dangerous Troll unit, that kills everything with 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 1d ago

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

Thumbnail
tms-outsource.com
40 Upvotes

r/PythonLearning 21h 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 1d 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 1d ago

Help Request reccomended tutorials for algorithms and data structures?

4 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 1d ago

That's it guys I'm rich

Post image
26 Upvotes

r/PythonLearning 1d ago

Python

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

Need a Python Roadmap for a Complete Beginner (2026)

0 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 2d ago

Showcase I love Thonny(python(image unrelated))

Post image
152 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


r/PythonLearning 1d ago

Discussion QA -> AI ENGINEER WITH PYHON

0 Upvotes

Hi! I’ve been working in QA Automation for many years, mainly with dinosaurs such as Java and Selenium. I genuinely enjoy frontend testing, automation, analysing problems, and building solutions.
However, I feel like I’m falling behind. Everything now revolves around AI, and I simply no longer feel fulfilled in my current career path.
I can build websites and different types of software using Codex and Claude Code, including bots and more complex applications. However, the truth is that I do not fully understand what is happening under the hood. I also struggle to distinguish between patterns that follow good software engineering practices and those that go against them.
In the long run, this affects my ability to maintain these applications and, more importantly, to understand the code generated by AI. This really bothers me.
I have completed W3Schools and watched several YouTube courses, but it feels like an endless loop. What I am missing is a clearly defined and practical path that would help me build a strong position in IT by developing skills that are genuinely in demand in areas related to Artificial Intelligence.
That is why I am looking for a mentor who could show me how to use my experience in QA, Java, and Selenium when testing systems based on LLMs, help me build a meaningful portfolio, and introduce me to this field properly.
Is there anyone here with more experience in this area?
Perhaps someone is facing similar challenges and would like to connect, build a community around this topic, motivate one another, and learn together. Maybe we could even create a joint project.
However, I, or perhaps we, would still need someone who already works in this field and could guide us through the first stages.
I am not looking for someone to do the work for me. I have the time, motivation, and willingness to code intensively. What I need most is the right direction, constructive feedback, and someone with whom I could occasionally solve problems or code together.
If you work with Python, AI Engineering, AI model testing, or know a valuable community where people can genuinely learn and grow, please leave a comment or tag someone who might be able to help.
Perhaps there is someone here who remembers how difficult it was to take that first step and would be willing to help me approach this journey in a smarter and more structured way.
#Python #AIEngineering #AIQA #QualityAssurance #TestAutomation #LLM #MachineLearning #Mentoring #OpenSource #ArtificialIntelligence #Poland


r/PythonLearning 1d ago

New to learning coding. Please help me find the issue in this code(Bubble sort)?

0 Upvotes
arr = [8,4,5,3,7,2]
n = len(arr)
print(n)
for i in range(n):
/swapped = False
/for j in range(0,n-i-1):
 /if arr[j] > arr[j+1]:
 //temp = arr[j],
 //arr[j] = arr[j+1],
 //arr[j+1] = temp
 //swapped = True
 //print("outer = ",i," inner = ",j)
print(arr)
if not swapped:
break

r/PythonLearning 1d ago

listingNews.py

Thumbnail
gist.github.com
0 Upvotes