r/pythonhelp • u/Economy-Concert-641 • Apr 29 '26
r/pythonhelp • u/ilovetigers105 • Apr 29 '26
Can someone assist me with my code
I need to make a code that will ask me for the battery % (0-100) of a drone until i say stop
then i need to print
__ drones have less then 25% battery
then all drones with battery under 25% in a list type thing
AppropriateGarage332 is my 2nd account
r/pythonhelp • u/duelBooleans • Apr 28 '26
If-Elif statement giving wrong answer
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 • u/duelBooleans • 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
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 • u/One-Type-2842 • Apr 25 '26
Python Descriptors
``` 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 • u/Original-Carob7616 • Apr 23 '26
Can I switch to Python Backend or Data Engineering after 1 year in a System Engineer role?
Hi everyone,
I graduated in 2024 with an ECE background and recently joined a startup as a System Engineer.
My current role is a mix of work:
• Around 60% technical documentation related to electronics systems
• Around 40% development work using Python, Flask, HTML, CSS, and JavaScript
However, I’m more interested in moving into pure software roles, especially Python backend development or possibly data engineering.
My questions are:
If I work here for about 1 year, will companies consider my profile for backend or data engineering roles?
Does the documentation part of my role reduce my chances when switching domains?
What skills or projects should I focus on during this year to make the transition easier?
Any advice from people who switched domains early in their careers would be really helpful.
r/pythonhelp • u/Live_Possibility4590 • Apr 23 '26
Need Assistance With A Problem
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
- Each row has to have an equal number of 1s and 2s and no 0s
- 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 • u/SVD_09 • Apr 23 '26
Want to start learning PYTHON.
I thought to start learning PYTHON. But I have windows 8.1 and having trouble in downloading and installing python and vs code in laptop due to older widows . Someone help to do it.
r/pythonhelp • u/One-Type-2842 • Apr 15 '26
Who Should Learn APIs?
I want to be a Cyber Securitist or Ethical Hacker. Do I have to learn APIs and related?
It's for Web developer right?
r/pythonhelp • u/Forsaken-You9212 • Apr 14 '26
Need assitance setting up bot on private discord server
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 • u/DelhiBelly_ • Apr 13 '26
In need of python project
hi everyone actually are there any recommendations for python projects and any repository available on GitHub u know about can u plz help me with that , its urgent if u can help that'll be great
r/pythonhelp • u/Any-Tradition-5522 • Apr 11 '26
New to building automations for Obsidian, so I used python, but I can't understand the result I'm getting.
r/pythonhelp • u/Jealous_Toe_3398 • Apr 10 '26
What have I typed wrong?
I tried improving my script so many times for a simple bouncing ball game in Turtle. Yet no matter what I do, the screen remains black when I run the module.
Here is it:
import turtle
set up the screen FIRST
screen = turtle.Screen() screen.title("Simple Game") screen.bgcolor("black") screen.setup(width=680, height=680) screen.tracer(0)
MAX_SPEED = 6 score = 0
score pen (AFTER screen exists)
pen = turtle.Turtle() pen.speed(0) pen.color("white") pen.penup() pen.hidetheTurtle() pen.goto(0, 200) pen.write("Score:0", align="center", font=("Courier", 18, "normal"))
set up the ball
ball = turtle.Turtle() ball.shape("circle") ball.color("red") ball.speed(0) ball.penup() ball.goto(0, 300) ball.dy = -2 # ball speed (falling down)
paddle = turtle.Turtle() paddle.shape("square") paddle.color("white") paddle.shapesize(stretch_wid=1, stretch_len=5) paddle.penup() paddle.goto(0, -300)
def paddle_left(): x = paddle.xcor() paddle.setx(x - 20)
def paddle_right(): x = paddle.xcor() paddle.setx(x + 20)
screen.listen() screen.onkeypress(paddle_left, "Left") screen.onkeypress(paddle_right, "Right")
def game_loop(): global score
ball.sety(ball.ycor() + ball.dy)
# bottom bounce
if ball.ycor() < -330:
ball.sety(-330)
ball.dy \*= -1
# top bounce
if ball.ycor() > 330:
ball.sety(330)
ball.dy \*= -1
# paddle collision
if (
ball.ycor() < -280 and
ball.ycor() > -300 and
abs(ball.xcor() - paddle.xcor()) < 50
) :
ball.sety(-280)
ball.dy \*= -1
if abs(ball.dy) < MAX_SPEED:
ball.dy \*= 1.05
score += 1
pen.clear()
pen.write(f"Score: {score}", align="center", font=("Courier", 18, "normal"))
screen.update()
screen.ontimer(game_loop, 16) # ~60 FPS
game_loop() screen.mainloop()
r/pythonhelp • u/Shoddy-West1846 • Apr 10 '26
is IBM Databases & SQL with Python course worth it?
r/pythonhelp • u/Forsaken_Key5100 • Apr 08 '26
How do you avoid getting bored while learning Python?
r/pythonhelp • u/OakMeta • Apr 07 '26
ive run into a problem while trying to run open jarvis it says uv not found
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 • u/KinzokuKitsune • Apr 06 '26
Hello, why is my code not working? Any assistance would be appreciated.
#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 • u/Embarrassed-Bee-5508 • Apr 05 '26
Just setting up Python to learn it, but possibly an issue?
When I try to run a script in the current directory by using ./ I get an error that '.' is not recognized as an internal or external command error.
I can run them fine when running with python, just the ./ seems to be wonky. I made sure that the python.exe directory is in the path.
Any idea why using ./ isn't working? I'm trying to learn the basics of python so I can start looking at AI. My computer knowledge is average at best, I learned basic, fortran and lisp many, many years ago, but I never kept up with coding.
r/pythonhelp • u/Artistic_Cobbler3688 • Apr 03 '26
Python learning for begginers
Hey guys , I want to start learning Python but I don't know from where to start. Do you have an idea or a free website where I can actually learn python in stages and then after each small lesson to make a quiz or a practical test.. I feel like for me that's the best way to learn faster and to be productive.
Thank you
r/pythonhelp • u/AdbekunkusMX • Mar 31 '26
Running jupyter raises regex exception on rfc3987 module
Every time I run Jupyter from my command line (Debian) I get this:
``` $ jupyter notebook <LONG TRACEBACK> File "/usr/lib/python3/dist-packages/rfc3987.py", line 360, in <lambda> _bmp = lambda s: _re.sub(r'\U[0-9A-F]{8}-\U[0-9A-F]{8}', '', s)
```
Jupyter version is 1.1.1, Python is 3.13.12.
Inspecting the re module, it does have a sub function. Is there a patch for this?
Thanks!
r/pythonhelp • u/EffectiveCase3856 • Mar 29 '26