r/learnpython

Python, from graph import

hi everyone, I've been assigned a programming project, and using from graph import and other simple commands like triangle, I need to create a geometric abstraction image. Please help me, and you can create any image of your choice, preferably of medium difficulty, and provide a link to it🙏

reddit.com
u/Despair19 — 5 hours ago

Can't understand for loops after an hour

I've looked through other posts on this, and none of them address my problem, and neither do any tutorials. I've tried to understand and I just can't wrap my head around it.

names = ['bob','jim','bill','kate']
for name in names:
print(name)

I see stuff this thrown around a bunch but this is complete nonsense to me. The word 'name' quite literally is not in the list. For 'name' in names, print 'name'? It doesn't print name though, it prints the stuff in the list. And even if the word name were in the list, it doesn't print the list, it does it all individually, even though there's no indication on why it would do that. What don't I get??

Edit: A few people have explained that the code is essentially putting "name' into the list to assign it to a string within that list, and then printing the result of that, until the list has run out. Thanks!

reddit.com
u/AileNarrator — 15 hours ago

Should i buy 100 days of code by dr angela? Currently on sale just 5 dollars (400rs)

Should i buy the course in 2026 . I already know python basics till oops . I saw the course structure from outside it looked good. Is it still revelent? Please drop your reviews and guide me

reddit.com
u/Significant-Book6927 — 12 hours ago

How to not Vibecode?

Many people have something against Vibe-Coders, so here's my question as a beginner (kinda): how do you create code for a project, 100% without using AI? I mean it is probably possible, but isn't it difficult? I would like to hear as many opinions as possible to this topic (sry if my English was bad) 🤔

reddit.com
u/SilentThread292 — 14 hours ago

I'm 13 and I love coding, but AI makes me feel like I have no future. Am I wasting my time?"

I’m 13 years old and I’ve been into programming for a while now. But lately, I’ve been feeling really anxious about my future, and I’m looking for some perspective from adults who are already in the industry.

Seeing how fast AI is evolving—writing code better, faster, and more efficiently than I ever could—makes me wonder if I’m wasting my time learning the fundamentals. I have a few specific concerns:

* **The market is oversaturated.** Everyone says there are too many developers already. If AI takes over the routine tasks that used to be the entry point for juniors, will there even be a place for me by the time I graduate?

* **The loss of purpose.** I spend a lot of time trying to understand how systems work, learning languages and architecture. But am I just becoming an "AI operator"? I’m terrified that I’ll end up being dependent on algorithms, never truly mastering the craft myself.

* **The impossible competition.** How do you compete with something that never gets tired, doesn’t make typos, and knows the entire documentation of every language by heart? Is there still a niche where human judgment is truly irreplaceable?

I’d love to hear from those of you who have seen the industry change over the years. Is it still worth "grinding" and learning how to code from scratch, or should I be preparing for the fact that programming as a profession is changing into something completely different?

Do I actually have a future in this field, or am I just fighting a losing battle against AI?

reddit.com
u/Dobin_human — 12 hours ago

How do I turn my code into a website?

Not sure if I’m posting in the right sub, but I’ve been working on this project for a couple years and I’m almost done with it. I plan on building a website using my code, but I have no idea where to even begin.

For context, my code involves obtaining lead data from EPA documents. I gather max values, min values, and dates. I’m basically simplifying the information and I’d like to display it as a public website where the data is easier to understand than what the EPA publishes.

For example, I would like for the user to be able to select a year that displays values and provides the date the value was received.

I’ve heard of applications like Flask and Django, but I’m not sure if this is what I need for my specific project? Any advice would help, and if this is the wrong sub, please direct me to a better one.

reddit.com
u/EquivalentAcademic93 — 12 hours ago

Day - 02 of learning python as a 17 year old with no programming knowledge.

Before starting off with today's updates and progess i would like to ask about your opinions on the thought that my my brother said that as you are 17 you should not do python as programming and coding is getting taken over by ai and now anyone can make a website and that I'm a fool that I'm learning python and I should instead focus on getting a government college as I'm from biology stream and I'm thinking of going in medical . I would like to know about your thoughts as I look to my brother and always listens to his words so I can't help but feel demotivated and I can't decide whether his words make sense or i should just ignire him or study more hard and do python over other things I do .

Keeping that aside , Today I started off with making a about me code as I said on my post Tommorow that I'll do it today .

After that I started off with some keywords of python such as False , True , None and got to know how case or alphabet sensitive python is and how much one uppercase kr lowercase matter and can mess up things .

After that I solved some print sum problems using operators generally arigmated operators ( i hope my spelling is correct) and I'm thinking of practicing by making some projects by using ai to generate some questions for me .

Then I learnd about operator , not all but all four main operators which consisted logical , assignment , comparing and arigmated ( again i hope my spelling is correct) operators and implemented them in some codes I made for eg I took one variable a = 20 and another variable gg = 50 and and then I used one assignment operators += to write gg += a and then I used code print(gg) . I'm also doing 2 to 4 projects Tommorow and I think I'll make my GitHub soon so that I can post my Lil projects or codes so that my progress is visible

I also learnd about single and double - line comment and shortcut to change any code in comment fast which was ctrl + forward slash .

Thx and I hope anyone seeing this post will also see my post Tommorow about my day - 3

And I'm also not able to post some of my projects ss because community doesn't allow or there is some issue with my reddit .

reddit.com
u/Some-Level-858 — 14 hours ago

Grade 6 student trying to make a game in Python — where should I start?

Hi everyone,

I’m a Grade 6 student and I really want to make my own game using Python. I’m very new to coding, but I’ve started learning basic things like variables, loops, and printing text.

My goal is to eventually make a simple game, maybe something like a platformer, adventure game, or even just a fun mini-game. Right now I don’t really know what tools or libraries I should learn first.

I have a few questions:

  • Is Python a good language for beginners who want to make games?
  • What should I learn before trying to build a game?
  • Should I use something like Pygame, or is there something easier?
  • What are some small beginner projects I can practice with first?
  • Any YouTube channels, websites, or tutorials you recommend for kids/beginners?

I know I probably won’t make a huge game right away, but I really want to learn step by step. Any advice would help a lot. Thanks!

reddit.com
u/tyfgfjfnfjvivufjfn — 17 hours ago

Is learning with AI a good thing?

I learned Python with AI because I would ask it for exercises to practice and understand the language. Once I had written the code, I would send it to the AI and it would correct it, telling me where there were errors or what could be improved without sending me the completed code directly.

But what do you think? Is it okay to use AI to learn Python or any programming language?

reddit.com
u/3lCiruja — 14 hours ago

What’s the best and safest way to compile Python code into a DLL?

Hi everyone,
I have a full Python application that I’d like to compile into a DLL so it can be integrated and used from another application on Windows. My main goal is to make distribution easier while also protecting the source code as much as possible and keeping good performance and stability.

I’ve been looking into options like Cython, Nuitka, pybind11, and embedding Python, but I’m still not sure what the best real-world approach is for converting an entire project instead of just a small module.

Is there any method that is considered significantly safer or harder to reverse engineer? Or is Python code inside a DLL still relatively easy to extract? I’m also wondering if people usually end up rewriting the whole project in C/C++ when they need a truly secure DLL.

I’d really appreciate recommendations or advice from anyone who has done this before.

reddit.com
u/Substantial_Cake9855 — 13 hours ago

How do I make it so I’m able to play a full at bat

I’m making a baseball simulation game. And I have it so you are able to decide to take a pitch swing or bunt . I have it where you can choose but it only lets you choose once then it moves on here’s my code:

import random

def play_game(lineup):
batter_index = 0
your_score = 0
cpu_score = 0

input("\nPress Enter to start the game...")

for inning in range(1, 10):

print("\n===========")
print("Inning", inning)
print("===========")

outs = 0

first_base = False
second_base = False
third_base = False

runs_this_inning = 0

while outs < 3:

batter = lineup[batter_index]
print("\nBatting:", batter)

if batter == "YOU":

print("1. Take pitch")
print("2. Swing")
print("3. Bunt")

choice = input("Choose 1-3: ")

if choice == "1":
result = random.choice(["Ball", "Strike"])
print("Result:", result)

elif choice == "2":
result = random.choice(["Groundout", "Flyout", "Single", "Double", "Home Run"])
print("Result:", result)

elif choice == "3":
result = "Out"
print("Result: Bunt attempt = Out")

else:
result = "Out"

if result in ["Groundout", "Flyout", "Out"]:
outs += 1

elif result == "Single":
if third_base:
runs_this_inning += 1
third_base = second_base
second_base = first_base
first_base = True

elif result == "Double":
if third_base:
runs_this_inning += 1
if second_base:
runs_this_inning += 1
third_base = first_base
second_base = True
first_base = False

elif result == "Home Run":
runs = 1
if first_base:
runs += 1
if second_base:
runs += 1
if third_base:
runs += 1

runs_this_inning += runs

first_base = False
second_base = False
third_base = False

else:
result = random.choice([
"Strikeout",
"Groundout",
"Flyout",
"Walk",
"Single",
"Double",
"Home Run"
])

print("Result:", result)

if result in ["Strikeout", "Flyout", "Groundout"]:
outs += 1

elif result == "Single":
if third_base:
runs_this_inning += 1
third_base = second_base
second_base = first_base
first_base = True

elif result == "Double":
if third_base:
runs_this_inning += 1
if second_base:
runs_this_inning += 1
third_base = first_base
second_base = True
first_base = False

elif result == "Home Run":
runs = 1
if first_base:
runs += 1
if second_base:
runs += 1
if third_base:
runs += 1

runs_this_inning += runs

first_base = False
second_base = False
third_base = False

elif result == "Walk":
if not first_base:
first_base = True
elif not second_base:
second_base = True
elif not third_base:
third_base = True

batter_index += 1
if batter_index == len(lineup):
batter_index = 0

print("Outs:", outs)

your_score += runs_this_inning

print("\n--- End Inning ---")
print("You:", your_score)
print("CPU:", cpu_score)
print("Runs this inning:", runs_this_inning)

input("\nPress Enter to continue...")

reddit.com
u/DemocraticHellDiver1 — 13 hours ago

I know this is basic question but please answer it,

PYTHON Is pop function used only to remove last element in a list or you can actually mention a particular index in parenthesis and remove it from the list from that particular position

My teacher argued that pop cannot be used to remove item from particular position

But she removed majority of my marks for this even though it is correct Edit: sorry I didn't know about documentation Plus I didn't have much time to get my answer sheets checked and get marks nor anyone if us had laptops with us so I just showed chatgpt answer 😔 I am very novice don't judge😔

reddit.com
u/Wooden_Seaweed8973 — 20 hours ago
▲ 4 r/learnpython+1 crossposts

How to start with GitHub (mobile)

Learnt python functions and everything with practice projects and stuff

classes ,loops , functions, file handling and stuff

I use an app called solo learn to save my projects and pydroid

recently learnt pandas

I remember someone telling me that GitHub is like a platform to Store ,go back to a certain point in code which helps us make projects and also it acts like a place where we can store our projects for professional purpose

should I focus on it via mobile or can I just get general tips regarding git or what I should learn altogether (want to be a data engineer or go to ai/machine learning)

I am just 15 so please advise accordingly

reddit.com
u/Justicemirm — 16 hours ago

3 part scraping workflow help

Hey all, I’ll try to keep this brief. Long story short I’m trying to learn how to use python without relying on vibecoding out the wazoo.

One of the ideas I had is a three part workflow that would compare mathematics requirements for different electrical engineering majors at different universities.

  1. Scour the internet from a base browser or landing pages of preselected universities (if moving internally is possible), to find electrical engineering major information, and, output those links to a csv.

  2. From the link CSV, gather the relevant information about math courses.

  3. Output the data into another CSV AND json file (I want to be able to customize the csv output columns from within the script). From the csv, I want hyperlinks for the specific math courses (or, more links to be scraped if the info comes from a PDF curriculum url).
    4th (optional): it’d be cool if a local llm could compare and reason the similarities/differences between the math courses.

I work in helpdesk but am otherwise a beginner. What is the best place to learn how to do these functions, and what are my options with making this?

reddit.com
u/Interesting-City1703 — 13 hours ago

I was tired of manually typing terminal inputs SO many times to test my python programs, so I did something about it

hey guys, if you're taking CS, more specifically learning python, in school and code your programs in VS Code, i'm sure y'all know the absolute pain of having to type the exact same inputs into the terminal 50 times just to test if your code works.

it was driving me insane so i actually built a VS Code extension to fix it. it basically uses AI to look at what your program is prompting for, automatically types the inputs into the terminal, and runs the whole thing for you.

if you want to try it out and save yourself some time just search up Terminal AutoInput - Dhiya Raja, wherever you guys find your extensions.

let me know if it helps or if you find any bugs.

oh and for it to work, after you guys download the extension you have to press ctrl + shift + p which turns on the AutoInput after that you can run your code watch as everything in the terminal runs automatically with no extra effort from the user side!!

Edit for context: Seeing a few comments about input redirection/text piping or using advanced test suites, I appreciate the technical suggestions, but this extension isn't meant for complex backend frameworks!

I built this specifically for high school/introductory CS students (like CBSE practical prep) who are constantly writing basic, menu-driven interactive scripts that rely heavily on manual keyboard input() prompts in the terminal. No student wants to manage a messy bunch of static .txt input files just to test if a quick condition block works during lab practice. This is just a lightweight quality-of-life tool to keep things fast and frictionless directly inside the native VS Code terminal.

reddit.com
u/Reasonable_Ad1300 — 20 hours ago

Writing scripts using Scapy library

Hello!

I’m new to this sub. I’ve recently decided to refresh and continue learning python farther. I’m still rather new but I am trying to learn python by writing code in relation to my field/interests.

I want to write a program that will essentially be a wireless scanning suite. I want to be able to scan, detect, and log stuff like AP’s, SSID, BSSID, MAC, BLE, BT, RSSI, and Probe Requests. It seems like the best way to do it is using the Scapy library. My only issue is that I am having a hard time finding tutorials for coding with the library. Most videos/tutorials are just using the shell/cmd instead of using the library inside of an ISE.

Does anyone have experience with using the Scapy library with python? I’m not asking to be spoon fed answers, but just to be pointed in the right direction with getting started and building into more complexity (local web server that hosts an interactive gui that updates in real time with data gathered from a tool).

Thanks!

(After making this post, I see that I may have to make a separate section for BT and BLE using something other than Scapy)

(Only intended for ETHICAL purposes only! I do not condone any unethical and or illegal usage and or practices.)

reddit.com
u/Deep_Telephone_5060 — 17 hours ago

Question about documenting functions

Question about adding documentation into your code (either for a future you or someone else). I'm self taught and I've been making a real effort to figure out home to do things the "right" way or more Pythonic way since I finished my PhD.

Is there a standard way of documenting your functions?

Below are two examples. The first is what I do now. I'm forgetful, so this helps when I come back to code much MUCH later. I don't have to parse the code much to know what it does. The second is what I think is closer to what people do? I recently learned about the 'typing' module and also learned about doc strings (like, six months ago).

If there's a standard, are these close? Is there a better way to do it? Am I worrying about minutia that I should just not worry about? Any advice would be super helpful. Thanks in advance (and sorry about formatting)!

Examples:

def heavilyDocumented(a, b, c):

"""

Purpose:    Here's what it does

Args:       a (int) - here's what the number represents

            b (dict) - {"this is a descriptive key" : its_value}

            c (str) - again, just saying what this represents

Return:     Here's a description of what the return is (str)

"""

print("and the code goes here")

def lessDocumented(a: int, b: dict, c: str) -> str:

"""Here's what the function does"""

print("and the code goes here")
reddit.com
u/DecoherentDoc — 22 hours ago

Best approach to recover Python source code from a compiled .exe file?

Hello everyone,

I’m currently analyzing a Windows executable that was originally developed in Python and later compiled into a .exe file (likely using tools such as PyInstaller, cx_Freeze, or similar).

I would like to understand the most effective and professional approach for recovering or reconstructing the original Python source code from the executable.

Thank you in advance.

reddit.com
u/Substantial_Cake9855 — 22 hours ago

Any tips on teaching someone python?

A family member of mine was paying for lessons on python and while I’m still kinda intermediate level I said you can easily just learn by yourself and save money to which they then replied they’ll pay me to teach them and I mean I’m getting paid so why not. I think the lessons are gonna be 30mins - hr once a week unfortunately not a lot of time but yh. I just wanted to ask for some advice on how to effectively teach him.

reddit.com
u/AggravatingDeal8192 — 24 hours ago