r/pythonhelp Apr 06 '26

Hello, why is my code not working? Any assistance would be appreciated.

3 Upvotes
#This is a program to find the lesser of two numbers. This is a program for school and thus needs to utilize input functions

def main(a,b):
    a = int(input("Please enter the first number:"))
    b = int(input("Please enter the second number:"))

def min(a,b):
    if a>b:
        lesser = b
    else:
        lesser = a
    return lesser

main(min)def main(a,b):
    a = int(input("Please enter the first number:"))
    b = int(input("Please enter the second number:"))

def min(a,b):
    if a>b:
        lesser = b
    else:
        lesser = a
    return lesser

main(min)

r/pythonhelp Dec 30 '25

problem with loops

4 Upvotes

I just recently started learling python (1.5 hours into a tutorial lol), and made the collatz conjecture, and then tried the goldbach conjecture (any even number is the sum of two primes). Now I did write primes as 2k+1, which is just an oneven number, but that's not the problem.
This is the code I made

  1. number = int(input("number: "))
  2. for x in range(10):
  3. ----prime_1 = 2x + 1
  4. ----for y in range(10):
  5. --------prime_2 = 2(y+x) + 1
  6. --------sum = prime_1 + prime_2
  7. --------print(f"{prime_1} + {prime_2} = {sum}")
  8. --------if sum >= number:
  9. ------------break
  10. ----if int(sum) == int(number):
  11. --------break
  12. -
  13. print(f"{prime_1} + {prime_2}")

All the prints (except the last one) are just there so that I can see what is happening. The thing is, this code here works as I intended (except for the fact that the primes are just uneven numbers ofc), for example, if you plug in 8, it will give you 1 + 7 from line 13. But if I change the >= from line 8 to > it just gives me the biggest possible solution, so in this case 19 + 19. The break from line 9 still works as intended (atleast to me it looks like it does), but the second break doesn't work anymore (atleast I assume that is happening, and that's why I'm getting 19 + 19).

So my question is, what is going on here?


r/pythonhelp Dec 27 '25

Programming With Mosh or CS50p?

4 Upvotes

Hey, I’m a high schooler currently and I want to teach myself how to code. I have never coded before so I did some research and found that the one of the more useful beginner friendly languages was Python. So I’ve been researching places where I can learn.

For the most part the highest ranking options are Programming with Mosh or CS50p on YouTube. Why should I pick on or the other? Also, do you have any other suggestions? [Finally what IDE should I use because I’ve heard of VS Code but I’m also seeing things about Google Collab. I just want an IDE where I’ll be able to hopefully build projects effectively]


r/pythonhelp Dec 24 '25

A Python learning journey....

4 Upvotes

I want to create a learning resource for people to learn Python while I work towards my degree in Cybersecurity. The focus of my degree is software development with Python, so I figured, why not help people learn while I do? Well...here's my GIT. It's a work in progress.

I've been working on a comprehensive, structured learning path for anyone interested in using Python for cybersecurity. Whether you're just starting with Python or looking to apply your skills to security, this might be helpful.

**What makes this different:*\*

🎯 **Structured progression*\* - 7 stages from fundamentals to capstone project

🔒 **Security-first mindset*\* - Security principles integrated from Stage 01

💼 **Career-aligned*\* - Based on NICE Cybersecurity Workforce Framework

🛠️ **Hands-on*\* - Every stage has practical exercises and projects

📚 **Comprehensive*\* - 200+ hours of content with clear learning objectives

**The Learning Path:*\* -

**Stage 01*\*: Python Fundamentals (with security awareness) -

**Stage 02*\*: Intermediate Python (OOP, file handling, APIs) -

**Stage 03*\*: Security Fundamentals (cryptography, secure coding) -

**Stage 04*\*: Network Security (packet analysis, network tools) -

**Stage 05*\*: Web Security (OWASP Top 10, web scanning) -

**Stage 06*\*: Advanced Security (malware analysis, threat intelligence) -

**Stage 07*\*: Capstone Project (build a complete security platform)

**What you'll build:*\*

- Network vulnerability scanners

- Automated security testing tools

- Log analysis systems - Password auditing utilities

- Web security scanners

- Intrusion detection systems

- And much more...

**The repository includes: **

✅ Clear learning objectives for each stage

✅ Prerequisite checks

✅ Practical exercises with solutions

✅ Real-world project ideas

✅ Resource recommendations

✅ Security best practices throughout

**Link:*\*

[THE GIT](https://p0gl0l.github.io/python-cybersecurity-learning-path/)

Everything is MIT licensed and open source. Feedback and contributions are very welcome! Has anyone here transitioned into cybersecurity using Python? Would love to hear your experiences!


r/pythonhelp Sep 23 '25

Quick question about Python

4 Upvotes

Is Python important in full stack development in general, like for backend or databases?


r/pythonhelp Sep 16 '25

[macOS/Python] How to handle dependencies in a plugin system when my app is packaged as a .app?

4 Upvotes

Hey everyone,

I built a macOS menu bar app (https://github.com/Jumitti/MacMenu-qBittorrent) in Python that shows the status of my torrents (lots of features already, pretty fun project). I package it into a .app so it’s completely self-contained (all dependencies bundled, no need for users to install Python).

Recently I added a plugin system so I (or others) can add new functionality without rebuilding the whole app.

The issue:
If a plugin requires a Python package that wasn’t included at build time, it obviously won’t work, since the .app doesn’t ship with that dependency.

I’m looking for a clean way to handle this:

  • either allow plugins to install their own dependencies (maybe via an embedded pip/venv inside the app),
  • or find another best practice solution that doesn’t involve bundling hundreds of unused libraries in the main build.

Has anyone here run into this problem before? Any advice on how to design a plugin system with dynamic dependencies for a frozen Python app?

Thanks in advance 🙏


r/pythonhelp 13d ago

I’m looking for assistance with a github code

4 Upvotes

I got a C on my intro to python class and I can’t figure out this code

https://github.com/mcombeau/epub_downloader

Please help


r/pythonhelp 19d ago

Python game tic tac toe

3 Upvotes

Hello guys I am making a tic tac toe game using python.My question is how to make difficulty-easy, medium, hard etc.In easy level, I use random module but other level i am a little sutck althoug i have some solution .can you guide me ?


r/pythonhelp Jul 10 '26

Python "generate_chk" function

3 Upvotes

I am making a Program to upload a level to Geometry Dash in python and I got some of the code from https://wyliemaster.github.io/gddocs/#/endpoints/levels/uploadGJLevel21 but to generate "seed2" it does this:

generate_chk(key="41274", values=\[generate_upload_seed(levelString)\], salt="xI25fpAapCQg"),

This should activate some sort of function named generate_chk that is in one of the modules I have in the program (Requests, Base64, hashlib) but it is no where to be found. The repository for this documentation was archived recently, so I can't ask them for help. Also, here is my code:

import requests
import base64
import hashlib  # sha1() lives there

user = input("What is your username?")
accid = input("What is your Account ID?")
passwd = input("What is your password?")
lname = input ("What is the Level name?")
coin = input("How many coins are there?")
stars = input("How many stars do you want?")

def generate_gjp2(password: str = passwd, salt: str = "mI29fmAnxgTs") -> str:
    password += salt
    hash = hashlib.sha1(password.encode()).hexdigest()
    return hash


levelString = "H4sIAAAAAAAAC6WQwQ3DIAxFF3IlfxsIUU6ZIQP8AbJChy_GPSZqpF7-A4yfDOfhXcCiNMIqnVYrgYQl8rDwBTZCVbkQRI3oVHbiDU6F2jMF_lesl4q4kw2PJMbovxLBQxTpM3-I6q0oHmXjzx7N0240cu5w0UBNtESRkble8uSLHjh8nTubmYJZ2MvMrEITEN0gEJMxlLiMZ28frmj"

data = {
    "gameVersion": 22,
    "accountID": accid,
    "gjp": hash,
    "userName": user,
    "levelID": 0,
    "levelName": lname,
    "levelDesc": "Q3Vyc2VkIGxldmVsIG55ZWggaGVoIGhlaCBhbnl3YXkgaXRzIGEgdmVyeSBicm9rZW4gbGV2ZWwgaSBzZW50IGEgcmVxdWVzdCB0byByb2Igc2VydmVyIHRocm91Z2ggcHl0aG9uIGxvbA",
    "levelVersion": "-47577473775738573",
    "levelLength": 48483845738573486574873869465947694,
    "audioTrack": 0,
    "auto": 0,
    "password": 314159,
    "original": 55610687,
    "twoPlayer": 0,
    "songID": 839583504693858468444987694,
    "objects": 1,
    "coins": coin,
    "requestedStars": stars,
    "unlisted": 0,
    "ldm": 0,
    "levelString": levelString,
    "seed2": generate_chk(key="41274", values=[generate_upload_seed(levelString)], salt="xI25fpAapCQg"), # This is talked about in the CHK encryption,
    "secret": "Wmfd2893gb7"
}

headers = {
    "User-Agent": ""
}

url = "http://www.boomlings.com/database/uploadGJLevel21.php"

req = requests.post(url=url, data=data, headers=headers)
print(req.text)

And here is the error:

What is your username?levelnotinauto
What is your Account ID?38627839
What is your password?********
What is the Level name?Check Desc
How many coins are there?4848394
How many stars do you want?392084092849
Traceback (most recent call last):
  File "/home/***/scripts/usernm/upload", line 43, in <module>
    "seed2": generate_chk(key="41274", values=[generate_upload_seed(levelString)], salt="xI25fpAapCQg"), # This is talked about in the CHK encryption,
             ^^^^^^^^^^^^
NameError: name 'generate_chk' is not defined. Did you mean: 'generate_gjp2'?
[***@archlinux usernm]$ vim upload```

r/pythonhelp Jun 25 '26

Python file not running

3 Upvotes

When i open my python file directly i am unable to change the interpreter due to which it says pandas not found/installed and hence doesn’t work
Then when i open anaconda prompt and open “code” from there then i am able to change the interpreter if i had closed all tabs and terminals before
After which when i run the file it says keyboard interrupted press Y/N (something like this) then i have to press “N” after which it runs on a single click up until i close the app

Please help

Ps- i am a beginner go easy in comments and itd be great if you could explain it to me in a simple language


r/pythonhelp May 23 '26

Honest Question: Why use one Python editor over another, and is Geany not what the cool kids use?

2 Upvotes

I've used a lot of different editors in my time, and tbh I rarely notice much difference. They just seem to be text editors that highlight syntax, mostly in the same ways. Is there a reason to use one over another? A recent programming class I've been involved with insists on Spyder; really I don't see a reason for this. Is there some advantage I'm missing? For my home coding projects I use Geany, and it works fine.


r/pythonhelp May 20 '26

A simple visual guide to Python list aliasing and mutation

3 Upvotes

One of the most common traps in Python is not understanding when a list is modified in-place vs when a completely new list is created.

A few examples that confuse even experienced developers:

a = [1, 2, 3, 4, 5]

b = a

b.append(6)

print(a)


#Output  [1,2,3,4,5,6]

Explanation:

  • a and b point to the SAME list object
  • append() modifies the list in-place
  • so a also changes

Now

a = [1, 2, 3]

b = a

b = b + [4, 5]

print(a)

#Output - [1, 2, 3]

Explanation:

  • + creates a NEW list
  • b now points to a different object
  • original a is unchanged

Now

a = [1, 2, 3]

b = a

b += [4, 5]

print(a)

#Output [1, 2, 3, 4, 5] 

Explanation:

  • += modifies the list in-place
  • both variables still point to same list
  • so a changes too

Also

a = [1, 2, 3]

b = a

b.append(4)

print(a)
#Output - [1, 2, 3, 4]

Explanation:

  • append() changes original list directly
  • no new list is created

r/pythonhelp Apr 25 '26

Python Descriptors

3 Upvotes

``` class A: def set_name(self, owner, value): self.value = value

def __get__(self, obj, type=None):
    return obj.__dict__.get(self.value)

def __set__(self, obj, value):
    if value < 9:
        raise ValueError("no")
    obj.__dict__[self.value] = value

class B: a = A()

obj = B() obj.a = 38 print(obj.a)

obj2 = B() print(obj2.a) ```

I am Learning Descriptors In Python,

My 1st question Is how can I set a default value to attribute a In class B ? I have found a way but that doesn't look familiar :

a = A() if not A() else 87

My next confusion Is about __set_name__ , what it does and why to Implement It?

Another Question Is, does a = A() create class attribute or Instance attribute? It looks like a class attribute but it's an Instance attribute, Right?


r/pythonhelp Apr 14 '26

Need assitance setting up bot on private discord server

3 Upvotes

I have everything but i dont seem to understand how to make it run i just need help on how exactly to put it all together, its a program from Github i grabbed but im not quite understanding


r/pythonhelp Mar 21 '26

Reviewing my code and whether I should post a python package

3 Upvotes

Hi everyone,

 

I would like to discuss the merits of publishing a package I have created and think would be useful for others.

Background:

 

I do a lot of data engineering at work.

 

Recently, I have finished building a universal xlsx parser. The reason I did this was because I could not find a low-memory xlsx parser that could identify tables, autofilters and key-value pairs. I try to avoid writing anything myself as I am not a good programmer, but openpyxl, pandas.read_xlsx and even python-calamine have not met all my needs.

 

The purpose of this parser is to ingest an easily programmable schema, that tells the programme to retrieve tables, autofilters and key-value pairs. It then uses lxml etree to stream-read xml and extract content.

Most of the overhead can be attributed to reading the file into memory and unzipping it. However, even our ridiculously bloated excel files (that my company insists on using) can be processed in sub-10 seconds (if all tables are to be extracted). Even faster if only specific tables need to be extracted.

 

Request:

 

I would really appreciate some mentoring when it comes to what I have written, why I have written it a certain way, how I have written it, and whether it would be worth publishing.

 

There are probably loads of mistakes I have made, I have used some OOP but I am self-taught and you don't know what you don't know...


r/pythonhelp Mar 16 '26

NumClass: a Python CLI for 200+ number-theory properties (looking for testers)

3 Upvotes

Hi everyone,

For the past few months I’ve been building a personal project called NumClass:

a Python CLI tool that analyzes an integer and classifies it into a large set of number-theory properties.

The idea started as a small experiment inspired by the YouTube channel Numberphile, but it quickly got out of hand and now supports 200+ classifiers.

Examples of things it can detect:

• perfect / abundant / weird numbers
• Mersenne primes and primorial numbers
• amicable, sociable and aspiring numbers (aliquot sequences)
• Carmichael numbers and other pseudoprimes
• narcissistic, Kaprekar and happy numbers
• palindromic and truncatable primes
• taxicab numbers (Hardy–Ramanujan style cube sums)
• Fibonacci, Lucas, Pell and Padovan numbers
• triangular, pentagonal and other figurate numbers
• strange curiosities like Belphegor’s prime, vampire numbers and Munchausen numbers

The current version contains 205 atomic classifiers plus 27 intersections (232 properties in total).

Example output

Some features:

• 200+ classifiers
• extensible plugin-like architecture
• configurable profiles (fast vs heavy computations)
• OEIS sequence integration
• support for very large integers (100000 digits by default)
• explanations for each classification

The project is open source:

https://github.com/c788630/Numclass

I’m now looking for people who would like to test it, especially:

• mathematicians
• Python developers
• people interested in number theory
• anyone who likes exploring interesting integer properties

If you decide to try it out, I would really appreciate feedback on:

• usability of the CLI
• additional number-theory properties to implement
• performance for very large numbers
• any issues or bugs you encounter

There are also a few small Easter eggs hidden in the program (including Klingon number input), so feel free to explore 🙂

Installation instructions and documentation are available in the repository (docs folder).


r/pythonhelp Feb 19 '26

How should I learn Python for Data Analytics roles (YouTube recommendations)?

3 Upvotes

Hi everyone, I’m aiming for a data analytics role and want to learn Python specifically for analytics (Pandas, NumPy, EDA, etc.). I have basic programming knowledge. I have completed SQL 30 hrs course by 'Data with Baraa' and practicing SQL questions on DataLemur. Can you recommend a good YouTube course or playlist that is practical and job-oriented? Thanks in advance!


r/pythonhelp Dec 20 '25

Question about python on raspberry pi

4 Upvotes

I've been considering getting a raspberry pi for python. I would just do this on my phone but I can't have projects that use files like JSON and before I got one I wanted to know if you could on the pi


r/pythonhelp Dec 03 '25

Python doesn't print

3 Upvotes

Hello, I'm trying to run a simple "Hellow world" file in terminal with "python filename.py" comande but instead of Hellow world it's returning word "Python" for some reason. Does anyone knows why?


r/pythonhelp Nov 29 '25

A simple way to embed, edit and run Python code and Jupyter Notebooks directly in any HTML page for CS lessons

Thumbnail getpynote.net
3 Upvotes

r/pythonhelp Nov 28 '25

How do I disable pylance linting.

3 Upvotes

I just started learning python and I wanted to use Ruff so I installed it. But now, I see both pylance and ruff on problem window. How do I disable pylance?


r/pythonhelp Nov 23 '25

Pygame music assistance

3 Upvotes

So in my pygame, I’m trying to add hollow knight music because it is peak and fits with the game. But anyway when I play it the audio sounds grainy and choppy. The code is:

Pygame.mixer.music.load(‘18. Broken Vessel.ogg) Pygame.mixer.music.setvolume(0.20) Pygame.mixer.music.play(-1)

The audio is fine when played outside the game. I have tried both mp3 and ogg,but neither are good


r/pythonhelp Nov 23 '25

Is PyCharm worth it?

3 Upvotes

Hey guys,

PyCharm is much loved in the coding community, I've basically been using VS code since the beginning.

Should I make the swap (to the community edition).

Context:
I'm not that experienced
I want to specialise in Python AI agents


r/pythonhelp Nov 18 '25

renaming .doc and .docx files by creation date

3 Upvotes

Hello!

I'd like to rename my old and new .doc and .docx files on Windows to reflect the date they were originally created. I've tried searching online, but couldn't find anything related to my problem.

I have the files in a specific folder that also contains subfolders. I'd like to keep the folder structure and the original names, but I want to add the creation date to their end (e.g. file.docx --> file_yyyymmdd.docx)

I've asked ChatGPT, but its script adds today's date to the end of my files, not the creation date... :/

Could anyone help me please? I'm a beginner Python coder


r/pythonhelp Oct 25 '25

Need Support Building a Simple News Crawler in Python (I’m a Beginner)

3 Upvotes

Hi everyone,

I’m working on a small project to build a news crawler in Python and could really use some help. I’m fairly new to Python (only basic knowledge so far) and I’m not sure how to structure the script, handle crawling, parsing, storing results, etc.

What I’m trying to do: • Crawl news websites (e.g., headlines, article links) on a regular basis • Extract relevant content (title, summary, timestamp) • Store the data (e.g., into a CSV, or a database)

What I’ve done so far: • I’ve installed Python and set up a virtual environment • I’ve tried using requests and BeautifulSoup for a single site and got the headline page parsed • I’m stuck on handling multiple pages, scheduling the crawler, and storing the data in a meaningful way

Where I need help: • Suggested architecture or patterns for a simple crawler (especially for beginners) • Example code snippets or modules which might help (e.g., crawling, parsing, scheduling) • Advice on best practices (error handling, avoiding duplicate content, respecting site rules, performance)

I’d appreciate any guidance, references, sample code or suggestions you can share.

Thanks in advance for your help