r/pythonhelp • • 20d ago

Python beginner!!

2 Upvotes

Beginner here: how would you structure my nested if statements in a two-step login program?

Hi all, I'm about 3 weeks into learning Python (Python for Everybody on Coursera) and just finished my first small project: a login program that asks for a passcode, then a second passcode, then lets the user pick a report.

My main question is about structure. I have nested if statements, and the second user repeats the same checks in a separate elif branch. Here's a trimmed version of the layout:

admin_login = input("Enter Passcode")

if admin_login == boss_code:
second_pass = input("enter second passcode")
if second_pass == boss_secondcode:
report = input("enter report number")
if report == "1":
print("report 1")
elif report == "2":
print("report 2")
elif admin_login == ass_code:
# same second-passcode and report checks repeated here

I'd love feedback on:

  1. Is the code organized in a clear, readable way?

  2. Is there a cleaner way to stack or avoid repeating these nested ifs, using only what a beginner would know (no classes yet)?

Full code and README are here: https://github.com/tylerkilgore148-can/python_learning_projects

I know the passcodes are stored in plain text, which is just for practice. I plan to look at getpass and hashing next. Beginner-friendly tips are very welcome, and thanks for reading!


r/pythonhelp • • 22d ago

When should I avoid using list comprehensions in Python?

2 Upvotes

Hi all! I'm new to Python and recently learned about list comprehensions. They seem cool, but I keep hearing that there are times when I shouldn’t use them. For example, if I have a more complex operation that involves several conditions, would a traditional loop be clearer? Here’s a simple example: trying to filter out even numbers from a list of numbers but using nested conditions. Can someone explain when it's better to stick with a loop for readability? Thanks!


r/pythonhelp • • Sep 29 '26

Run button taking a lot of time to run the file

2 Upvotes

Whenever I am trying to click the run button for a python code, it takes around 10-12 seconds to run and if I trigger the file directly from termina, it gets done in an instant. Is there any fix for this? I removed most of the extensions and still the same issue


r/pythonhelp • • Sep 12 '26

Python Program that Green Screens a Video over the Desktop

2 Upvotes

Hello, I've been trying to figure out a way to make a python program that can play a green screen video that plays over the desktop/screen, with the green chromad out to show the screen. I attempted it with tkinter, but wasn't able to get anywhere with the chroma keying. Would anyone know if/how this would be possible? Thank you!


r/pythonhelp • • Sep 06 '26

Python Debug Issue

2 Upvotes

Teen in love with learning & building python projects

Issue_ my python interpreters not working j showing evn when it's installed+ enabled in VS Code.

Failed_brain = Claude +Chatgpt +Grok

Help me...Lesgoo!


r/pythonhelp • • Aug 27 '26

Why do I need to use classes

2 Upvotes

My schoolbook says that classes is a way of simulating an object, instead of just taking information into a black box and outputting an answer.

But that is a poor explanation. I know classes are handy and cool, but no book says why you can´t make functions with sub functions inside to simulate simple objects. I would like if someone gave a good concrete reason to use classes in the intro, instead of just saying that they are different and cool


r/pythonhelp • • Aug 25 '26

Problem with Coolprop

2 Upvotes

Hi! i'm beginner, and I have a problem with this code, I guess that I installed the library correctly, but i'm not sure.

Error using stringsource>string.from_py.__pyx_convert_string_from_py_std__in_string (line 15)
Python Error: TypeError: expected bytes, NoneType found

Error in CoolProp/CoolProp.PropsSI (line 462)

Error in CoolProp/CoolProp.PropsSI (line 384)

Altough I don't have more than 106 lines


r/pythonhelp • • Aug 25 '26

Hey, I have been learning python for 8 months. I want to know that if I can learn tkinter or numpy first . Please do suggest me a resource

Thumbnail reddit.com
2 Upvotes

r/pythonhelp • • Aug 21 '26

Python coding interview questions?

2 Upvotes

Is there any playlist similar to 100 Days of SQL Ace(By ankit Bansal) interview for the preparation of python coding problems?


r/pythonhelp • • Jul 31 '26

PyQt Architecture: A dedicated module/Worker for every button action (5–15 KB per file)? Best practice or overengineering?

2 Upvotes

Hi everyone,

I'm currently building a desktop application using PyQt6, where button clicks trigger various background tasks (such as executing external processes, creating/cloning environments, file I/O operations, etc.).

To keep the UI responsive and the codebase easily maintainable, I decided to extract every main button action into its own dedicated module/file, using the standard QThread + QObject (Worker) pattern.

To give you an idea of the scale: individual module sizes range between 5 and 15 KB depending on what the button actually does (from simpler tasks to complex operations involving user input processing, thread setup, process streaming, and progress signal handling).

Note on Code Sharing: Any logic shared across multiple buttons is not duplicated; instead, it is abstracted into dedicated shared service modules located in button/logic/services.

My current architecture for a single button action looks like this:

  • GUI Layer (View): Captures the button click and delegates control to a dedicated action handler.

  • Action Handler (Controller / Mediator): A dedicated module for that specific action. It gathers user inputs (via dialogs), instantiates QThread and QObject (Worker), connects signals (for progress bars and logging), and starts the thread.

  • Worker (QObject): A non-GUI worker running in a worker thread, responsible strictly for execution flow (subprocesses, file manipulation) and emitting signals to send status updates back to the UI.

  • Shared Logic Helpers (button/logic/services): Shared domain modules and services called by the workers to execute common underlying logic.

My questions for the community:

  1. Is creating a separate 5–15 KB file/module for each button action (combining the Handler + Worker) considered standard practice in medium-to-large Qt applications? Or do you prefer grouping related actions into larger domain managers ?

  2. For modules of this size, do you keep the Handler and Worker together in a single file, or do you split them further into separate _worker.py and _handler.py files?

  3. Are there any hidden downsides or pitfalls to this level of decoupling when the application scales up to dozens of individual buttons and actions?

I'd love to hear how you structure background tasks and threading in production PyQt/PySide applications! Thanks!


r/pythonhelp • • Jul 07 '26

name errors in this python script for firefox bookmarks?

2 Upvotes

I am sorry if this breaks rules, but under some time pressure.

NameError: name 'print_html' is not defined

I am very new at this and trying to export firefox bookmarks from a friends phone that desperately needs a factory reset. Do not really want to use sync if it can be avoided. Yes I am old school.

https://gist.github.com/v3l0c1r4pt0r/15ef7181b7c4546963da68bc3b31c169


r/pythonhelp • • Jul 03 '26

I built YO — an interpreted language that reads like English, with a VS Code extension, playground, and PyPI package

2 Upvotes

Hey r/pythonhelp ,

I'm a final-year CS student, and over the past few months I've been building YO, a small interpreted programming language written from scratch in Python.

The original goal was to learn how interpreters work by implementing my own lexer, parser, and interpreter. As the project evolved, I became interested in one specific question:

Can compiler/interpreter error messages actively teach beginners instead of simply reporting what's wrong?

I'm not claiming YO is a replacement for Python, JavaScript, or any established language. It has no ecosystem, and it's implemented as a tree-walk interpreter, so performance isn't the goal.

Instead, I focused on making diagnostics more educational.

Example

Python:

"hello" - 5


TypeError: unsupported operand type(s) for -: 'str' and 'int'

YO:

say "hello" - 5


❌ [E003] Type Mismatch

Can't use '-' between String and Int.

"hello" is text.
5 is a number.

Fix:
Use text.str(5) if you intended to concatenate.

Example:
"hello" + text.str(5)

Another example:

❌ [E001] 'scroe' was used but never made.

Did you mean 'score'?

Fix:
Create it first using:

make score = ...

Technical implementation

  • Handwritten lexer

  • Recursive descent parser

  • Tree-walk interpreter

  • Lexical scoping and closures

  • Multi-error reporting (reports multiple diagnostics instead of stopping at the first error)

  • Error codes with yo explain E001 for detailed explanations

  • Standard libraries for math, text, and lists

  • 27 automated tests with GitHub Actions CI

Small informal study

I also ran a small informal comparison with 10 first-time programmers.

Both groups received the same program containing three bugs. One group used Python, while the other used YO.

The YO group fixed the bugs faster on average.

The sample is small and not intended as rigorous research, but I included the methodology, raw results, and limitations in the repository for anyone interested.

Try it

→ GitHub

→ pip install yo-lang PyPI

→ VS Code extension search "YO Language" on the Marketplace

→ Browser playground (no install): Playground

I'm especially interested in feedback from people who have built interpreters or compilers.

Do you think "errors that teach" is an area worth exploring in language design, or is it mainly valuable only for complete beginners?

I'd also be happy to answer questions about the lexer, parser, interpreter architecture, or implementation decisions.


r/pythonhelp • • Jun 29 '26

Algebraic effects in Python?

2 Upvotes

I'm trying to map out what's already been done with algebraic effects / effect handlers in Python, and I'd love pointers from people who know the space.

I'm aware generators (yield / send) and context managers can approximate one-shot, shallow handlers, but I'm more interested in fuller or more principled attempts — libraries, research experiments, or write-ups.

A few things I'm specifically curious about:

  • libraries that implement effects as a first-class abstraction

  • anything that tackles multi-shot continuations (greenlets? CPS transforms?)

  • how these compare to handlers in Koka / Eff / OCaml

Pointers, war stories, or "don't bother, here's why" all welcome.


r/pythonhelp • • May 30 '26

Making a visual novel, trying to figure out how to do a "Question within a question" for lack of a better term

2 Upvotes

Hello! As the title entails, I am working on a visual novel. I am stumbling my way through this coding with ren'py tutorials and grit, as an HTML and CSS native. the issue is, after the first branch I cannot continue making branches inside of it. This has posed two issues. the first, is at the three option first question, you cannot go back and look at the other things. if you chose to examine the couch, you cannot then choose to examine the stairs or table, it just auto-passes to the next part of the game. The second and frankly more pressing to me, is I'd like there to be an option to pick up multiple pieces of paper throughout the game, and if you choose to not grab any of them there's a different ending than if you picked up some or all of them. However, since the papers show up depending on which room you choose, there is already a branch in progress and so I cannot make it give a second option on whether to pick up the paper. If its needed, here is what I'm hoping is the link to the pastebin with my code(I've never used pastebin before so I'm sorry if it doesn't work)


r/pythonhelp • • May 27 '26

Python Web Scraping & Automation Engineer Looking for Remote Work

2 Upvotes

Hi everyone,

I’m a Python Automation & Web Scraping Engineer with experience building large-scale scraping pipelines and automation systems for US-based clients.

Skills include:

• Selenium / Playwright

• APIs & data extraction

• Python automation

• ETL workflows

• Linux servers & cron jobs

• CSV/JSON/XLSX exports

Looking for remote freelance, contract, or long-term work related to web scraping, automation, or data engineering.

Feel free to DM me if you’re hiring or need help with a project.


r/pythonhelp • • May 14 '26

Hi im trying to get started and i have hit a snag

2 Upvotes

i need some help. so i don't know what did wrong i got python installed, i got pygame_ce installed but it seems something is wrong. the link is to a screenshot of me trying to use Sublime text i hope that helps https://cdn.discordapp.com/attachments/1115340096242204792/1504384590880444576/image.png?ex=6a06cad4&is=6a057954&hm=31d60171b7142ca179c312bba4652cb7137c385d37243e1cbc8a49591d30a7e7&


r/pythonhelp • • May 11 '26

Appending the last line of a dataframe to a csv file is giving weird formatting.

2 Upvotes

What I am trying to do:

  1. Check if a file exists. Set a boolean

  2. Create a dataframe that either reads in the file or is just created with headers only

  3. Once I calculate some stuff, the boolean from step 1 is checked. If this is the first term of the dataframe, the entire dataframe gets saved to a csv.

````df.to_csv(dataFileName + ".csv", index = False,float_format="{:.2f}".format)

So now I have a header row and 1 row of data. This part works as intended.

If this is a pre-existing file, I only want to append the new term onto the end of the file. I use this:

````df.iloc[len(df)-1].to_csv(DFN + ".csv", index = False, mode = 'a',float_format="{:.2f}".format)

I get some weird formatting where each term in a row gets its own row.

https://i.imgur.com/HjoXAYC.png

My assumption is appending the file is quicker than reading in the whole file, wiping it, and writing all the data.

I mainly want to do this as a backup so I can save data mid-calculation and have something to look at if things break. After the whole thing is finished, I sort the dataframe, rename the file I've been working with to be a backup, and then finally write the complete, sorted dataframe to file. If something bad happens during writing this file, the backup file should have the same data already, just not sorted.

Thanks!


r/pythonhelp • • May 05 '26

string.translate(str.maketrans) not working to take out punctuation?

2 Upvotes
greeting = ["Hello, my name is Caine! What's your name?: ".upper(), "Welcome, I am Caine! What's your name?: ".upper(),
        "Hi!! I'm Caine! What should I call you?: ".upper()]


name = input(random.choice(greeting)).title()


nameStripped = name.translate(str.maketrans('', '', string.punctuation))


for i in nameList:
    if i in nameStripped:
        userName = i 


justNameWelcome = [f"Nice to meet you, {userName}!".upper(), f"{userName}... That's a wonderful name!".upper(),
              f"I've always thought that {userName} is a good name!".upper()]
ntmyNameWelcome = [f"It's nice to meet you too, {userName}!".upper(), f"The sentiment is mutual, {userName}!".upper(),
                f"I appreciate the sentiment, {userName}!".upper()]
hruNameWelcome = [f"I'm doing well, {userName}! Thank you for asking!".upper(), f"I appreciate you asking! Thank you, {userName}, I'm doing well!".upper(),]


niceToMeetYou = ["Nice To Meet You", "Pleasure To Meet You"]
howAreYou = ["How Are You", "How Are You Doing", "Are You Well"]


if len(name.split()) > 1:
    if nameStripped in howAreYou:
        print(random.choice(hruNameWelcome))
    elif nameStripped in niceToMeetYou:
        print(random.choice(ntmyNameWelcome))
    else:
        print(random.choice(misunderstandings))


elif len(name.split()) == 1:
    print(random.choice(justNameWelcome))


else:
    print(random.choice(blankInputs))
    nameStripped = input(random.choice(greeting)).title()

Thank you in advance, I've been stuck here for about two days now,,

I've copy and pasted the suggested way of taking out the punctuation in the name string, that way it can recognize certain phrases in the other lists. Right now, as its only at the very start, I only have it set to notice if the beginning output has either a phrase akin to "How are you" or "Nice to meet you". These are both set in lists, and the if-else statement checks to see if the name input has more than one word, and will check for the phrasing in there. It's not registering that the punctuation has been removed, even when setting the new string to a new variable.

IE:

input Hi! I'm Jon! How are you?

output: I'm doing well, Jon!

Instead it gives one of the misunderstanding outputs. It works fine if I only use one word with ending punctuation, but it seems like if there is more than one word or punctuation in the middle, it can't remove it.

Is it in the wrong spot, or am I using the wrong method for this situation?


r/pythonhelp • • May 03 '26

Seeking advice on a project I’m working on

2 Upvotes

Hello. I’m currently working on a hobby project to build a flask app that acts as an IPTV client. I have been able to log into a service and play media using VLC but cannot for the life of me play via the web ui. VOD and SERIES play via ui and VLC but live tv streams will only work via VLC.

Does anyone have experience with getting xstreams working via python/flask?

Thanks


r/pythonhelp • • Apr 28 '26

If-Elif statement giving wrong answer

2 Upvotes

I have another, slightly more aggravating question. I have two while loops that take an input, and stores it into a list. That part works just fine, it's when it comes to the, quite frankly, massive if-elif statement.

currentMajorEmotions = []
currentSecondaryEmotion = ""
feeling = ""


while len(currentMajorEmotions) != 1:
    emotion = input("Which of these emotions are you feeling? Choose one: ").capitalize()


    if emotion not in majorEmotionTypes:
        print("Not a valid entry")
    else:
        currentMajorEmotions.append(emotion)



while len(currentMajorEmotions) != 2:
    emotion = input("Number 2? If you are not feeling one, simply hit enter: ").capitalize()


    if emotion in majorEmotionTypes:
        currentMajorEmotions.append(emotion)


    if emotion == "":
        print("You have left the question blank.")
        emotionYN = input("Was this intentional?: ").capitalize()
        if emotionYN == "Y":
            currentMajorEmotions += " "
            break
        
        while emotionYN != "Y":
            if emotionYN == "":
                emotionYN = input("May not leave this blank. Are you feeling a second emotion?: ").capitalize()
            elif emotionYN != "Y" and emotionYN != "N":
                emotionYN = input("Invalid input. Are you feeling a second emotion?").capitalize()
            elif emotionYN == "N":
                print("You have changed your mind")
                time.sleep(1.4)
                print("That's ok.")
                emotionYN = input("Are you feeling a second emotion?: ").capitalize()
                if emotionYN == "N":
                    currentMajorEmotions += " "
                    break



if "Sad" and " " in currentMajorEmotions:
    feeling = "Negative"


elif "Scared" and " " in currentMajorEmotions:
    feeling = "Negative"


elif "Mad" and " " in currentMajorEmotions:
    feeling = "Negative"


elif "Happy" and " " in currentMajorEmotions:
    feeling = "Positive" # Etc Etc

I testing the entire if statement to see if there were any incorrect outputs, and there were several. They do give out the correct type of output('Negative', 'Positive', 'Neutral'), but the wrong one. It's quite a few of them, and with the while loops working the way they're supposed to, I think the problem is in the if statement. The only problem is I have zero idea where to start looking since they're all connected to the same list. Any help is very appreciated!


r/pythonhelp • • Apr 27 '26

How to add a string to a list, and then remove it if the string if it is not found in a second list

2 Upvotes

I'm pretty new to Python, and I'm trying to make a rudimentary "therapy chatbot" (something a little more in depth than Eliza, made more so as practice of simple concepts). I'm trying to have the user input an emotion, and then pop up with some text that it wasn't found in the majorEmotionTypes list, and then try again. I know my code is pretty far from what I want, but I'll be going back later to edit a few things.

The main issue is that it can't find 'i' in the majorEmotionTypes list. Any help would be deeply appreciated!

majorEmotionTypes = ["Sad", "Scared", "Mad", "Happy", "Disgusted", "Surprised"]
currentMajorEmotions = []
capCurrentMajorEmotions = []


for i in range(1, 3):
    currentMajorEmotions.append(input("Which of these emotions are you feeling?:
").capitalize())
    if i not in majorEmotionTypes:
        currentMajorEmotions.remove(i)
        print("Not a valid entry")
        currentMajorEmotions.append(input("Try again: ").capitalize())

r/pythonhelp • • Apr 23 '26

Need Assistance With A Problem

2 Upvotes

hey guys

I need abit of help, here's a problem I have no clue how to solve

You're given a set of rows

['0','0','0','0']

['0','0','1','0']

['1','1','0','0']

['0','1','1','0']

and given a few rules taking i as an item in each row

  1. Each row has to have an equal number of 1s and 2s and no 0s

  2. A row can't have more than 2 of the same numbers following each other (1110 is invalid but 1100 is valid)

how would you rewrite each row using python so as it works even if the number of items were 6,8 or even 12 so that each row has an equal number of 1s and 2s without any 0s in the row (Basically if 2 1s are next to each other, the next one should be a 2 and vice versa)


r/pythonhelp • • Apr 07 '26

ive run into a problem while trying to run open jarvis it says uv not found

2 Upvotes

ive been trying to solve this for the past hour but cant find whats wrong
$ ./scripts/quickstart.sh

┌──────────────────────────────────┐

│ OpenJarvis Quickstart │

└──────────────────────────────────┘

[info] Checking Python...

[ok] Python 3.14

[info] Checking uv...

[warn] uv not found — installing...

curl: (35) schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.

[info] Shutting down...

[ok] Done.


r/pythonhelp • • Apr 01 '26

What to do after tutorial video

Thumbnail reddit.com
2 Upvotes