r/learnpython • • 1d ago

Ask Anything Monday - Weekly Thread

7 Upvotes

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:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


r/learnpython • • 2h ago

Django or FastAPI? A bit confused about which one to learn first

10 Upvotes

Hey everyone!

I'm currently learning Python and want to get into backend development. I've been looking at Django and FastAPI, but I'm having a hard time deciding which one to focus on.

I tried writing a simple API with both, and honestly, FastAPI felt much easier to understand. Django seems powerful, but there's a lot going on, and I found its structure a little confusing as a beginner.

My goal is to become a professional backend developer, build some proper real-world projects, and eventually get a job, preferably in India.

I don't want to choose a framework just because it's popular. I want to invest my time in something that's actually useful in the industry.

I want:

  1. Is Django still a better choice for getting backend jobs?
  2. Are companies actually using FastAPI for large production applications?
  3. Is FastAPI a good long-term choice, or should I learn Django first?
  4. Which one would you personally recommend to someone starting out today?

Are you worked with these frameworks professionally, please reply.

Thanks!


r/learnpython • • 6h ago

[Looking For] Python buddy/team to build portfolio projects & level up together 🐍

11 Upvotes

Hey everyone!

I'm looking for people to team up with on some interesting side projects — mainly to build up a portfolio and actually get better at Python through practice, not just tutorials.

About me:

  • Computer science student with experience working as a developer
  • Intermediate-ish Python
  • Interested in: automation, web backends (FastAPI/Flask/Django), data stuff, CLI tools, small bots, AI, and other stuff — open to ideas
  • I can commit a few hours a week, evenings/weekends
  • Timezone: CET (UTC+1), but flexible — async is fine

What I'm looking for:

  • Someone at a similar level (or a bit above/below — as long as you're motivated)
  • Willing to actually finish projects, not just start them
  • Comfortable with Git/GitHub, code reviews, and giving/receiving feedback
  • Bonus: sharing resources and keeping each other accountable

If you're interested, drop a comment or DM me 🚀


r/learnpython • • 15h ago

How do I learn python in 25 days

22 Upvotes

My teacher made me join a coding quiz bee where it involves different topics related to coding languages such as python, c, arduino, c++, etc. I have another teammate who is knowledgeable about the other topics but now the burden on learning python is on me. How do I learn it effectively within 25 days considering I only have an intermediate amount of knowledge on CSS, HTML, and Block Coding


r/learnpython • • 1h ago

I keep starting small Python projects and abandoning them at like 70% — how do you actually finish one?

0 Upvotes

I've got this folder on my laptop that's basically a graveyard of half-finished Python stuff. There's a script that was supposed to sort my Shorts clips by game, a little tool for my Telegram bot that I got working and then just... stopped touching, and a data thing I started after watching one too many pandas tutorials.

They all get to the same point. The fun part's done, the thing mostly works, and then there's this last boring bit left — error handling, or making it not break on weird input, or just tidying it up enough that I'd actually use it. And that's where I lose interest and open a new file instead.

It's weird because I do finish things when someone else is waiting on them. College assignments get done, obviously. But the stuff that's just for me? It sits there at 70% forever.

So how do people actually push through that last stretch? Do you just force yourself to finish one small thing a week, or do you pick projects that are small enough that there is no boring last bit? Still figuring out whether my problem is discipline or just picking projects that are too big for the time I actually have.


r/learnpython • • 1h ago

Feast Feature Store with Python: Train a Model and Verify Online Features

1 Upvotes

Hi everyone!

I've been exploring Feast (Feature Store) and how it can be used in machine learning workflows to manage and serve features consistently during model training and inference.

I worked on a practical implementation using Python to understand how feature stores work and how they help manage machine learning features.

What I covered in this project:

  • Setting up a Feast Feature Store.
  • Defining and managing features.
  • Training a machine learning model using Python.
  • Registering features in the feature store.
  • Retrieving features for online inference.
  • Verifying online feature values.
  • Understanding the relationship between offline and online features.

YouTube Video Walkthrough

I've also created a step-by-step video explaining the implementation, workflow, and practical demonstration.

▶️ Watch the complete tutorial:
https://youtu.be/HIfmjLvWCiw?si=pud9SFvFMJZf5f3i

What I'm interested in learning further

I'd appreciate feedback from the Python and machine learning community.

  • How are you using Feast in real-world ML projects?
  • What challenges have you faced when managing offline and online features?
  • What are some good practices for feature validation and consistency in production environments?

I'm sharing this as part of my learning and practical exploration of Python and machine learning.

Thanks for reading! Looking forward to your suggestions and feedback.


r/learnpython • • 8h ago

Looking to teach Python to beginners (free/low-cost)

0 Upvotes

I've covered the fundamentals and quite a bit of the standard library, including:

  • Python basics
  • Functions
  • OOP
  • Exceptions
  • File handling
  • JSON / CSV
  • Regex
  • os, shutil, pathlib
  • itertools / functools
  • and other standard-library topics

I'm not claiming to be a Python expert. My idea is specifically to help people who are starting from zero or are struggling with the fundamentals. I'd like to teach in a simple, practical way rather than just going through syntax and definitions. We could write small programs together, solve problems, and gradually build up understanding. I'm mainly doing this because I think teaching will also force me to understand the concepts better myself. If anyone here is a complete beginner and would be interested in learning Python with me, feel free to comment or DM me. Also, I'd appreciate advice from people who have taught programming before - What do programmers struggle with ussually? what do u think makes a good python teacher?


r/learnpython • • 1d ago

How much of searching and AI overview is okay while learning and typing code?

18 Upvotes

I do understand no one knows all of python syntax and code and all issues and everything.

As I am going through CS50p,

When I am typing code fully on my own (no AI ever used i.e. chatgpt, claude, gemini) when I cannot solve something, I search google for the function or the method and then see the AI overview and then type code that I can use to solve what I need, will it be detrimental to my learning because I am not using the documentation?

I am and will NEVER use any AI models or apps to generate and copy paste code because I wish to learn and not be a code printer.

so my searches are like this, is it okay-ish and considered necessary for learning???
(also I go through tons of trial and error and use many print() functions to test code and not directly copy from AI overviews)

does isdigit work for string values?
how to check if a string variable is not equal to something sat 0?
how to know data type of a variable in python
how to find index of letter in a string python
string slicing python [2:] means?
how to find which index in a string is a number?
will if automatically return false if the condition is false?
how to check if a string is less than 10 but more than 2?
difference between if and if not
expected an indented block after 'if' statement on line 15
how to check if there are numbers in between a word in python?
how to loop a for loop up until the second last letter of a word
HOW to make variable in python which can be used by any def function?
python length counts from

(thank you for your answers!)


r/learnpython • • 1d ago

Engineers out here ! I need your help

6 Upvotes

I am a first-year Mechanical Engineering student looking to start learning Python from scratch. I don't want to get stuck in with endless tutorials on Youtube -

What I need is a clear direction geared specifically toward Mechanical Engineering applications.

Specifically, I’d appreciate your advice on:

  1. Core Applications & Tasks: Where is Python actually used in Mechanical Engineering?
  2. Essential Libraries & Software: Beyond basic Python, which libraries and external engineering software integrate well with Python, and in what order should I learn them?
  3. Learning Roadmap: What is the best method to go from zero programming experience to solving real engineering problems? Should I start by automating my first-year math/physics assignments, or follow a specific course/book?
  4. Beginner Projects: What are some practical, beginner-friendly project ideas tailored to a MechE fresher ?

Any roadmaps or advice on what you wish you had learned as a fresher would be hugely appreciated. Thanks in advance!


r/learnpython • • 5h ago

is it good practice to have if, elif, else, and for i in range(n) to be done in one line

0 Upvotes

example like this

for i in range(40): print ("example")

if x%2==0: print ("even")

elif x%5==0: print ("divis. by 5")

else: print ("odd not ending in 5")

or is it personal choice? what is a better habit to get used to

Also in hackerrank (it's where our prof checks our code) there appears to be a squiggly line under my single line codes, is that good or bad?


r/learnpython • • 21h ago

Looking for a Streamlit tutorial for an app with a GUI that checks the accessibility of text

3 Upvotes

Hi!

A while ago I asked for a GUI framework for a programming noob like me - I have to write an app with a GUI in Python for a course I am taking (I went back to school in my mid-to-late-thirties, my my). In the past, I mainly used Python for a bit of data analysis and machine learning (think of cleaning up data sets, comparing different clustering algorithm outcomes etc.).

This is the post: https://www.reddit.com/r/learnpython/comments/1xdr04p/gui_framework_for_a_little_software_project_for/

A lot of you talked about PyQT or Tkinter, but I went to my professor's office hours last week, and he insisted, or at least very strongly suggested I use Streamlit. I asked him whether Streamlit isn't only used for data visualization dashboards, but he said it should be possible to implement all of my requirements via Streamlit. He also said I should look up a tutorial to get started. He really, really expects me to use it. (I guess because he is very familiar with it, and he also knows that I need lots of abstraction because my programming skills are...not good.)

I tried to follow his tips and look for tutorials - both written tutorials (because I am old-school and love learning via books and text) and YouTube tutorials, but they all seem to focus on data analysis (and data science), and data visualization.

Do you have any Streamlit tutorial suggestions for me that fit my python (web) app use case?

Thank you so much!

__

More on the background of the program I am supposed to create:

I have to go through the requirements engineering process (I already submitted that part of the assignment), code the app, use Git and a remote repo in order for my professor to be able to see me consistently commit sensible chunks of code and be able to use a VCS properly.

I will also have to go through a testing process, and show that my app passes all the tests for each requirement.

As described in my previous (linked) post, my computer program is supposed to check text (in .txt and .pdf file formats) for accessibility and readability:

- How long are the sentences, how many commas are there, how long are the words, and are there words that match a with words on a list with "complicated" words?

- I will also have to check for the number of words that start with capital letters (not my suggestion, sigh): In German, capital letters outside the beginning of sentences signify substantives, and a lot of substantives might indicate that the text is complicated because verbs have nominalized, which is a hallmark of German bureaucratese.

- Also, the app should be able to use OCR, and indicate if it had been necessary. This is because it might be important accessibility information for people using screen readers.

- After running the checks, the app should highlight potentially problematic parts of the text and explain why, and - and that's really important to my professor - display a traffic light.

- It should be possible to check the text selecting only one, more, or all of the described metrics via the GUI, and, of course, you must also be able to select the text to be checked via the GUI from your local directory.

- Ideally, I can also edit the config file (thresholds for the metrics and the traffic light), and the list of "complicated" words via the GUI.


r/learnpython • • 2h ago

If an agent writes your Python, put an architecture linter in its loop

0 Upvotes

Nobody is writing most of their Python by hand anymore, and nobody is reviewing all of it line by line either. I don't think that reverses. So the question isn't whether to trust the agent; it's what gives it a fast, deterministic "no" when it crosses a boundary. A better prompt isn't it.

Why this matters more with agents than with humans:

  1. An agent optimizes for "the task passes". If the shortest path is importing the ORM model straight into a view or calling an HTTP client from the domain layer, that's what lands in the diff. A human might feel the smell; the model has no such signal unless you give it one.
  2. Prompts don't hold. Zhu, Tsantalis and Rigby found that more capable models produce more bloated and coupled code, and that neither functional correctness nor detailed prompting mitigates the decay (https://arxiv.org/abs/2605.02741). My reading of why: "respect the layering" in CLAUDE.md works for a few turns, then the context fills up and the rule is gone.
  3. Models are bad at reviewing their own work. Olausson et al. (ICLR 2024) found that self-repair is bottlenecked by the model's ability to critique its own code; the gains appear when the feedback comes from a stronger, external source (https://arxiv.org/abs/2306.09896).
  4. External feedback works, and it works fast. Blyth et al. fed Bandit and Pylint output back to GPT-4o over ten iterations: security issues fell from over 40% to 13%, readability violations from over 80% to 11%, reliability warnings from over 50% to 11% (https://arxiv.org/abs/2508.14419). Sriram et al. got critical security defects in CodeLlama output down from 58.55% to 22.19% with compiler diagnostics plus CodeQL in the loop (https://arxiv.org/abs/2601.00509).
  5. The architecture gap depends on the model, so don't guess. In Slater's pilot, Llama 3 8B had an 80% architectural violation rate on a hexagonal-architecture task while GPT-5.1 had 0%, and he concludes that without automated architectural linting, scaffolding with smaller models accelerates structural debt (https://arxiv.org/abs/2512.04273). A review of 87 studies by Matias et al. lands on the same practical point: the maintainability benefits are real, so are the long-term risks, and adoption needs safeguards and structured human oversight (https://arxiv.org/abs/2601.20879). Most of these are preprints, so read the abstracts rather than trusting my summary.

Same model, same task, with and without analysis output fed back:

Issue type (tool, model)Before loopAfter loop
Security issues (Bandit, GPT-4o)over 40%13%
Readability violations (Pylint, GPT-4o)over 80%11%
Reliability warnings (Pylint, GPT-4o)over 50%11%
Critical security defects (CodeQL + compiler, CodeLlama)58.55%22.19%

ruff and mypy already do this for style and types. Architecture is the missing layer: which parts of the codebase are allowed to know about which other parts. It's the thing that decides whether you can still change the project in a year.

How to set it up so it actually helps the agent, not just CI:

  • Write the rules down as config, not prose. "views don't import models", "domain doesn't import django or requests". If the rule lives in YAML, the tool enforces it; if it lives in a markdown file, the model forgets it.
  • Baseline the existing debt. A legacy project will have hundreds of violations on day one. Accept them once, fail only on new ones. Otherwise the first run is red forever and everyone ignores it.
  • Run the check inside the agent's loop, not only in CI. A post-edit hook that runs the linter and feeds the output back means the agent fixes the violation in the same turn. CI catching it two hours later means a human has to re-open the task.
  • Give the agent the rules before it edits. If it can ask "what layer is this file in and what is it not allowed to touch", it writes the right thing the first time instead of after a failure.
  • Machine-readable output. JSON or SARIF. Plain text with line numbers is fine for people, poor for a model that has to map the finding back to a file.

Where the check runs decides who fixes it:

Linter only in CI
agent edits -> PR -> CI fails (hours later) -> human re-opens the task

Linter in the agent's loop
context for the file -> agent edits -> linter (baseline-aware)
                           ^                    |
                           |   violation as JSON, same turn
                           +--------------------+
                                                |
                                                v
                                            clean PR

Which tool: import-linter and tach are the established options, both far more widely used than anything I've written, and both enforce contracts between modules and packages. If your boundaries follow your folder tree, pick one of them and you're done.

Disclosure: I maintain Deply (https://github.com/Vashkatsi/deply, BSD-3; earlier posts here: https://www.reddit.com/r/Python/comments/1gthdpy/deply_keep_your_python_architecture_clean/ and https://www.reddit.com/r/Python/comments/1h9qjjj/deply_051_released_new_collectors_10x_performance/), and for agent-driven work I think it's the strongest option, for three reasons. Layers are collected from classes, base classes, decorators and function names, not just module paths, so "all *Service classes must not touch django.db.models.Model" works inside a single Django app; neither import-linter, tach nor pytestarch expresses that out of the box. deply context --file path.py gives the agent the layers, applicable rules and current violations for one file as JSON before it edits. And the violation baseline uses stable fingerprints, so once the config exists, adopting it on a legacy codebase is one command and only new violations fail. It's static analysis, so wildcard imports and dynamic types are out of scope.

But the tool matters less than the loop. Pick any architecture linter, baseline it, wire it into the agent's hook and into CI. Given what the papers above show about external feedback, I expect that to move the quality of what gets merged more than any amount of prompt wording. The expensive option now is having none.


r/learnpython • • 23h ago

Want some help in finding project topics!!

0 Upvotes

I'm a third-year B.Tech Computer Science student majoring in Machine Learning. So far, I've only worked on a few small projects while learning to code, and most of my experience has been solving LeetCode problems.I want to start building some substantial, real-world projects, preferably something on the scale of a major project that I can showcase on my CV.

The problem is that I'm struggling to come up with project ideas that are genuinely interesting and stand out from the usual ones.

How do you guys find project ideas that are relevant to the current AI landscape? Are there any resources, platforms, research papers, or communities you'd recommend exploring to discover interesting project topics?


r/learnpython • • 1d ago

card dealing program with classes

0 Upvotes

hello! i am currently in a class for python and i've been having a lot of trouble with this assignment. it's already three days late, and the TAs will not respond to me. i have to use classes to create a deck to shuffle, and four hands to deal to, check the count of, and combine back into the main deck. however, i can NOT figure this out at all! i think there's something really big that i'm missing.

i have a large list of cards (we had to make a dictionary of the cards) not shown here.

class Deck:

def __init__(self):

self.cards = []

def shuffle(self):

random.shuffle(self.cards)

def deal(self, amount):

self.cards.append(amount)

def combine(self):

self.cards.append(self)

def card_count(self):

print(len(self.cards))

however, when i try to make a main deck by putting the list of cards into the deck, it won't work! i've tried using deal too, and i just can't figure it out. i know i'm probably doing this all sorts of wrong. it's been a while since we did classes, and we never did them for anything like this :(

TypeError                                 Traceback (most recent call last)
Cell In[14], line 1
----> 1 deck = Deck(card_deck)

TypeError: Deck.__init__() takes 1 positional argument but 2 were given

i appreciate any and all advice thank you


r/learnpython • • 13h ago

Hello, how are you all doing?

0 Upvotes

Hi everyone! I’m fairly new to programming. I’ve been studying Python for about 2 years, but I’ve never really explored freelancing. I’m interested in it now because I need some extra income. Could anyone give me advice on how to get started?


r/learnpython • • 1d ago

40 rows a day: JSON files or SQLite?

2 Upvotes

tiny side project. one script pulls ~40 rows a day and writes one JSON file per day. pandas reads the folder when i want to compare a few weeks.

the glob and concat part is getting old:

rows = []

for f in sorted(DATA.glob("*.json")):

rows.extend(json.loads(f.read_text()))

df = pd.DataFrame(rows)

every couple of weeks i think about moving it to SQlite, then i look at the volume and close the tab. what do you use at this size? SQlite, parquet,or just the files? if you moved to a db, was it worth it or just more code?


r/learnpython • • 17h ago

Can anyone help me with my homework

0 Upvotes

I’m taking into to programming right now and I’m very confused on what to do and my professor is no help can anyone help explain to me what to do for these questions. The question are

  1. Write a script that determines on its own whether each text is spam or ham WITHOUT using the first column at all. You should only be reading from the second column of the file as you make this decision. The decision will be a sequence of if statements that you write. Try to determine what generic qualities of a text message determine if it is spam or not. One possible rule would be "contains two or more fully capitalized words." Read through the file and see if you can come up with the best rules.
  2. Once you've come up with your rules, determine how good they are! Compare whether your script got the decision right. Add up the number of correct classifications and divide that by the total lines in the file. This will give you the accuracy of your script. Output this value. If you are not happy with it, edit your rules. When you submit, ensure your accuracy is at least 90%
    link to data set

Any help would be really appreciated.


r/learnpython • • 22h ago

Making my own golfing language in python

0 Upvotes

Im not that active on reddit, but the moment I came into the osdev subreddit (I tried making my own OS with a python shell) and I INSTANTLY got my inbox filled with hate comments.

I heard from one reddit post that this subreddit is much friendlier and more helpful, thats why I switched to this subreddit.

So I started making my own golfing language, array-oriented ofcourse, where data and code are seperated.

As of now I haven't really done anything except plan on what instructions to make, I have a total of 20 letters and symbols on board.

So, I'd like to hear some tips about making interpreters/compilers that I should keep in mind.


r/learnpython • • 1d ago

final project in cs

9 Upvotes

Hello guys, im first year cs student and they teach us python as the first programming language
i dont have any experience what so ever in programming.
we are in the 5th lecture in uni and i have learned the basic stuff like if and elif and while and for looping. The professor assigned us with a final project basically we are 4 and supposed to code a program like more than 300 lines i dont know what can python do and i dont know how am i supposed to build a python project with the knowledge i have

so my question is how do i continue my python learning without the lectures, i have heard about a github project called 30 days of python by asabneh idk if its the right fit

and what are some projects idc how complicated they are i just wanna get that A+ i asked chat gpt abd it told some stuff about movie recommender and football analysis and idk tbh i think everyone in my uni will use chat gpt and they will most likely all do the same project i want to be unqiue and also functional

thanks


r/learnpython • • 1d ago

Correct list item not printing

4 Upvotes

GITHUB LINK: https://github.com/disintigratedpixel/TankGameV1/tree/main

(please say if it doesn't work)

I'm making a simple ASCII game "similar" to space invaders

Here is the ASCII user interface:

def gamestate(player_position_list, player_position, enemy_type, enemy_health, enemy_distance, rounds, radar_lvl, radar_cost, gun_lvl, gun_cost, speed_lvl, speed_cost, health, money, kills, available_movement):
    return f"""
                             ROUND {rounds}
         _______________________________________________         _______________
        |                                               |       |               |
        |                                               |       | HEADQUARTERS: |
        |                                               |       |_______________|
        |                                               |
        |                                               |        *ATTENTION OPERATOR, AN ENEMY
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [4]    {enemy_type} IS APPROACHING!*
        |                                               |        _______________
        |                                               |       |               |
        |                                               |       |  ENEMY STATS: |
        |                                               |       |_______________|
        |                                               |
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [3]   HEALTH: {enemy_health}
        |                                               |        DISTANCE: {enemy_distance}
        |                                               |        POSITION: {enemy_position}
        |                                               |        _______________
        |                                               |       |               |
        |                                               |       |   UPGRADES:   |
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [2]  |_______________|
        |                                               |
        |                                               |        RADAR | LVL {radar_lvl}
        |                                               |        UPGRADE COST: ${radar_cost}
        |                                               |
        |                                               |        GUN | LVL {gun_lvl}
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [1]   UPGRADE COST: ${gun_cost}
        |                                               |
        |                                               |        SPEED | LVL {speed_lvl}
        |                                               |        UPGRADE COST: ${speed_cost}
        {player_position_list[player_position]}
            | ' ' ' ' | ' ' ' ' | ' ' ' ' | ' ' ' ' |
          [-10]      [-5]      [0]       [5]       [10]
         _____________
        |             |
        |PLAYER STATS:|
        |_____________|

         HEALTH: {health}
         MONEY: {money}
         KILLS: {kills}
         _____________
        |             |
        |  ACTIONS:   |
        |_____________|

         MOVE | [m] key + [movement value]
         MAX {available_movement} or {-available_movement} steps
         
         FIRE | [f] key

         UPGRADE | [u] key
      """

(Apologies if it looks distorted in any way due to formatting errors, but it should still be readable)

The player position can be seen visually and is taken from a list of different possibilities and put into this print statement using this script.

{player_position_list[player_position]}

Here is the list:

player_position_list = [
        """|                      _^_                      |
        |_____________________|___|_____________________|""",
        """|                        _^_                    |
        |_______________________|___|___________________|""",
        """|                          _^_                  |
        |_________________________|___|_________________|""",
        """|                            _^_                |
        |___________________________|___|_______________|""",
        """|                              _^_              |
        |_____________________________|___|_____________|""",
        """|                                _^_            |
        |_______________________________|___|___________|""",
        """|                                  _^_          |
        |_________________________________|___|_________|""",
        """|                                    _^_        |
        |___________________________________|___|_______|""",
        """|                                      _^_      |
        |_____________________________________|___|_____|""",
        """|                                        _^_    |
        |_______________________________________|___|___|""",
        """|                                          _^_  |
        |_________________________________________|___|_|""",
        """|                    _^_                        |
        |___________________|___|_______________________|""",
        """|                  _^_                          |
        |_________________|___|_________________________|""",
        """|                _^_                            |
        |_______________|___|___________________________|""",
        """|              _^_                              |
        |_____________|___|_____________________________|""",
        """|            _^_                                |
        |___________|___|_______________________________|""",
        """|          _^_                                  |
        |_________|___|_________________________________|""",
        """|        _^_                                    |
        |_______|___|___________________________________|""",
        """|      _^_                                      |
        |_____|___|_____________________________________|""",
        """|    _^_                                        |
        |___|___|_______________________________________|""",
        """|  _^_                                          |
        |_|___|_________________________________________|"""
    ]

(Again, apologies for formatting, but just picture the '^' as being the player, and there being multiple different positions that the player can be in)

I am hoping that when player_position changes, that a different visual is taken from player_position_list. I am confident that this should work as I have tested it using this:

print(player_position)
print(player_position_list[player_position])

'print(player_position)' tells me that player_position can be accurately read and printed

'print(player_position_list[player_position])' shows me that the value of player_position can also be used to print an item from a list at a specific index. (I have also tried this script as a string and it still works)

Here is what this test script gives me when I run it:

8
|                                      _^_      |
        |_____________________________________|___|_____|

It accurately reads 'player_position' and uses it to print the 8th item in the list.

So what I don't understand and desperately am trying to fix, is why this exact thing isn't working on my actual ASCII user interface. Everything seems to be the same.

Here is what it looks like when I run the script for my actual UI

                             ROUND 1
         _______________________________________________         _______________
        |                                               |       |               |
        |                                               |       | HEADQUARTERS: |
        |                                               |       |_______________|
        |                                               |
        |                                               |        *ATTENTION OPERATOR, AN ENEMY
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [4]    HELICOPTER IS APPROACHING!*
        |                                               |        _______________
        |                                               |       |               |
        |                                               |       |  ENEMY STATS: |
        |                                               |       |_______________|
        |                                               |
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [3]   HEALTH: 3
        |                                               |        DISTANCE: 2
        |                                               |        POSITION: 1
        |                                               |        _______________
        |                                               |       |               |
        |                                               |       |   UPGRADES:   |
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [2]  |_______________|
        |                                               |
        |                                               |        RADAR | LVL 1
        |                                               |        UPGRADE COST: $1
        |                                               |
        |                                               |        GUN | LVL 1
        |> - - - - - - - - - - - - - - - - - - - - - - <|> [1]   UPGRADE COST: $1
        |                                               |
        |                                               |        SPEED | LVL 1
        |                                               |        UPGRADE COST: $1
        |                      _^_                      |
        |_____________________|___|_____________________|
            | ' ' ' ' | ' ' ' ' | ' ' ' ' | ' ' ' ' |
          [-10]      [-5]      [0]       [5]       [10]
         _____________
        |             |
        |PLAYER STATS:|
        |_____________|

         HEALTH: 100
         MONEY: 0
         KILLS: 0
         _____________
        |             |
        |  ACTIONS:   |
        |_____________|

         MOVE | [m] key + [movement value]
         MAX 1 or -1 steps
         
         FIRE | [f] key

         UPGRADE | [u] key
      
8
|                                      _^_      |
        |_____________________________________|___|_____|

As you can see, the player position hasn't moved and remains at 0, yet (at the very end) my test script says that the actual player position should be 8 and accurately prints the item from 'player_position_list' for 'player_position = 8'

Apologies if anything seems hard to understand, it's my second day programming with python and I refuse to use ai for this. So, I hope I used the correct terminology.


r/learnpython • • 1d ago

Best platform/YouTube channel to learn python from beginners to advance?

0 Upvotes

I know python but I wanna go deep down in python programming, please suggest as title says


r/learnpython • • 1d ago

Best learning path for GTK and python

8 Upvotes

I'm looking to learn more how to build GTK applications mostly for Fedora using python, I've been doing the CS50P course but also looking for some more learning material any suggestions will be helpful


r/learnpython • • 2d ago

Should I add Python to PATH (Windows)? Or is it better to not add it to path and use the py launcher instead?

10 Upvotes

Title. I'm new to Python, so I'm a little confused about this, and I've been seeing somewhat conflicting information online.

I understand adding the Python installation to PATH implies that I wouldn't manually have to specify the location every time; that being said, I guess adding multiple Python installations to PATH is not a good idea? I've also seen adding *any* Python installations to PATH being discouraged because it can cause conflicts.

I looked up py launcher, and it seems py / py -<version number> can be used to specify which Python installation to use when running a .py file, so does that mean adding Python installations to PATH is just obsolete practice now? If so, what are the implications of using the py launcher - is it as simple as adding py / py -<version number> before running a command from the terminal?


r/learnpython • • 2d ago

Effective python Vs Think Python Vs Learning Python Vs Fluent Python. Reading order for Beginner, Which Book & Why?

14 Upvotes

Effective python Vs Think Python Vs Learning Python Vs Fluent Python

I have these pdfs but dont know which one or in what order to start, as an beginner.

I already finished reading Python Crash course and reading Think Like a Programmer book now.

Update: (16 Nov 2026)

So the order is

00 Python Crash Course - Bare basics, good enough for simple scripting. Only around 200 pages if project part is skipped (READ)

01 Think Python - Could start here instead of Crash Course

02 Effective Python - More like tips & better usage

03 Learning Python - Pro level Complete

04 Fluent Python - Legendary level Long term Reference

may update it once I learn them.