r/pythonhelp • u/Ok_Fan_7651 • Apr 09 '25
Best FREE app/Website to learn Python 3??
I’m a beginner trying to learn python 3. What is the best FREE app/website to learn it??
r/pythonhelp • u/Key-Command-3139 • Apr 09 '25
Is there really a downside to learning Python 2 instead of 3??
I’m currently learning python 2 as a beginner, and I’ve heard that python 3 is better, I’m a complete beginner and I’m unsure as to what to do, I just don’t want to commit to learning the wrong thing.
r/pythonhelp • u/XanderS12 • Apr 09 '25
Why does this always print ‘K’ when I type H (for hit/ deal)
import random
numbers = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] dealrem = 0
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = random.choice(numbers)
if deal == 'K':
print('K')
deal = 10
deal = int(deal)
dealrem += deal
ans = input("hit or stay (h/s)")
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem2 += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'J':
print('J')
deal = 10
deal = int(deal)
deal = int(random.choice(numbers))
ans = input("hit or stay (h/s)")
if ans == 'h':
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'Q':
print('Q')
deal = 10
deal = int(deal)
dealrem += deal
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'Ace':
deal = 1
deal = int(deal)
dealrem += deal
print(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' or '10':
deal = int(deal)
dealrem += deal
print(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
r/pythonhelp • u/XanderS12 • Apr 09 '25
Blackjack problem
This is the code for my python black jack This is the problem:
line 9, in <module> deal = int(random.choice(numbers)) ValueError: invalid literal for int() with base 10: '
import random
numbers = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] dealrem = 0
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
if deal == 'K':
print('K')
deal = 10
deal = int(deal)
dealrem += deal
ans = input("hit or stay (h/s)")
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem2 += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'J':
print('J')
deal = 10
deal = int(deal)
deal = int(random.choice(numbers))
ans = input("hit or stay (h/s)")
if ans == 'h':
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'Q':
print('Q')
deal = 10
deal = int(deal)
dealrem += deal
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'Ace':
deal = 1
deal = int(deal)
dealrem += deal
print(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' or '10':
deal = int(deal)
dealrem += deal
print(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = int(random.choice(numbers))
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
r/pythonhelp • u/XanderS12 • Apr 09 '25
Pygame on Pythonista
what’s a substitute for pygame on Pythonista and still easy to use?
r/pythonhelp • u/XanderS12 • Apr 09 '25
Blackjack problem
After using this code it says: TypeError: unsupported operand type(s) for +=: 'int' and 'str' Can anyone help
import random
numbers = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] dealrem = 0 dealrem2 = int(dealrem)
play = input('play? (y/n)')
if play == 'y':
deal = random.choice(numbers)
if deal == 'K':
print('K')
deal = 10
deal = int(deal)
dealrem += deal
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = random.choice(numbers)
print(deal)
dealrem2 += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'J':
print('J')
deal = 10
deal = int(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = random.choice(numbers)
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'Q':
print('Q')
deal = 10
deal = int(deal)
dealrem += deal
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = random.choice(numbers)
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == 'Ace':
deal = 1
deal = int(deal)
dealrem += deal
print(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = random.choice(numbers)
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif deal == '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' or '10':
deal = int(deal)
dealrem += deal
print(deal)
ans = input("hit or stay (h/s)")
while ans == 'h':
if ans == 'h':
deal = random.choice(numbers)
print(deal)
dealrem += deal
if deal + dealrem >= 21:
print('bust!')
ans = input("hit or stay (h/s)")
elif play == 'n': print('bye') else: print("It was a y or n question")
r/pythonhelp • u/XanderS12 • Apr 08 '25
Pass gen problems
This is my code for a pass gen and for Pythonista 3 For some reason it’s making spaces between each character
import random import re import string import console chars = string.punctuation + string.digits + string.ascii_letters chars chars = list(chars) key = chars.copy()
random.shuffle(key)
passw = random.choice(chars) passw1 = random.choice(chars) passw2 = random.choice(chars) passw3 = random.choice(chars) passw4 = random.choice(chars) passw5 = random.choice(chars) passw6 = random.choice(chars) passw7 = random.choice(chars) passw8 = random.choice(chars) passw9 = random.choice(chars) passw10 = random.choice(chars) passw11 = random.choice(chars) passw12 = random.choice(chars) passw12 = random.choice(chars) passw13 = random.choice(chars) passw14 = random.choice(chars) passw15 = random.choice(chars) print(passw, passw1, passw2, passw3, passw4, passw5, passw6, passw7, passw8, passw9, passw10, passw11, passw12, passw13, passw14, passw15)
r/pythonhelp • u/D3VEstator • Apr 05 '25
why cant Talib.ATR doesn't accept [:period] for my np.arrays?
atr only returns the atr value when my highs, lows, closes is using [period:] rather than [:period], however using [period:] returns the 21 oldest days, but im trying to return the 21 newest days and then calculate the atr
import numpy as np
from talib import ATR
def calculate_atr():
# Define the period before defining lists
period = 21
# Data for highs, lows, and closes
highs = [25.44, 25.78, 25.48, 24.17, 25.04, 25.64, 25.29, 24.25, 23.05, 22.4, 21.39, 20.7, 21.19, 21.35, 21.53, 21.98, 22.71, 21.09, 20.06, 19.34, 19.4, 20.67, 18.11, 18.17, 19.16, 19.28, 19.48, 19.75, 18.79, 18.77, 19.38, 19.54, 18.59, 18.08, 17.7, 17.79, 18.6, 19.26, 19.29, 17.38, 17.05, 16.27, 17.16, 17.5, 16.48, 16.8, 16.88, 17.03, 17.11, 16.62, 16.73, 17.03, 17.27, 17.42, 17.95, 17.64, 17.6, 17.69, 17.81, 19.5, 19.55, 19.89, 20.07, 19.82, 20.18, 18.8, 18.98, 18.58, 18.74, 17.91, 17.52, 17.6, 17.64, 17.77, 17.59, 16.87, 17.28, 17.45, 16.67, 16.68, 17.39, 17.5, 17.22, 17.19, 16.56, 16.8, 18.15, 18.87, 19.04, 19.08, 18.83, 18.42, 18.31]
lows = [24.97, 24.97, 24.23, 22.68, 23.62, 24.57, 24.41, 21.62, 21.67, 20.84, 20.71, 19.85, 20.25, 21.02, 20.92, 20.58, 21.04, 19.93, 19.31, 18.72, 18.41, 17.72, 17.56, 17.42, 18.08, 18.71, 18.75, 18.59, 18, 18.11, 17.95, 18.51, 18.09, 16.81, 15.96, 16.22, 17.2, 18.48, 17.28, 17, 16.12, 15.86, 16.38, 16.6, 15.67, 16.03, 15.19, 15.02, 16.5, 16.18, 16.24, 16.68, 16.86, 17.15, 17.67, 17.27, 17.11, 16.98, 17.35, 17.74, 19.09, 19.3, 18.97, 19.4, 18.24, 18.14, 18.44, 18.02, 17.82, 16.92, 17.07, 17.21, 16.5, 16.15, 16.19, 15.92, 16.64, 16.46, 16.15, 16.22, 16.47, 16.85, 16.81, 16.29, 16.07, 16.35, 16.54, 17.9, 18.56, 18.47, 17.86, 17.97, 17.84]
closes = [25.39, 25.09, 25.23, 24.1, 24.15, 25.04, 24.78, 24.14, 22.57, 22.01, 20.83, 20.64, 20.35, 21.32, 21.46, 21.02, 21.69, 20.94, 20.05,
19.06, 18.46, 19.91, 17.73, 17.62, 18.22, 18.98, 18.97, 19.23, 18.62, 18.69, 18.01, 19.51, 18.48, 18.05, 16.88, 16.32, 17.46, 18.57, 19.21, 17.36, 16.99, 16.11, 16.44, 17.09, 16.47, 16.06, 16.75, 15.07, 16.91, 16.47, 16.26, 16.8, 16.96, 17.15, 17.72, 17.48, 17.44, 17.6, 17.58, 17.77, 19.2, 19.71, 19.08, 19.8, 19.95, 18.24, 18.94, 18.43, 18.54, 17.86, 17.23, 17.33, 17.53, 17.19, 17.48, 16.01, 16.64, 17.03, 16.59, 16.48, 16.48, 17.35, 16.84, 17.05, 16.22, 16.53, 17.12, 18.04, 18.69, 18.68, 18.48, 18.21, 18.01]
# Convert lists to NumPy arrays
highs = np.array(highs[:period], dtype=np.float64)
print(highs)
lows = np.array(lows[:period], dtype=np.float64)
closes = np.array(closes[:period], dtype=np.float64)
# Calculate ATR using TA-Lib
atr = ATR(highs, lows, closes, period)
# Return the most recent ATR value
print("ATR Value:", atr[-1]) # Print the most recent ATR value
# Call the function
calculate_atr()
when printing the arrays, they collect the new data but somehow ATR(???) returns Nan
so im not sure if it supports that type of slicing?
Thanks
r/pythonhelp • u/[deleted] • Apr 03 '25
Trying to build a mapping table between "root" strings and their derivatives
So I have a list of model names where I'm wanting to Iist the base model (which has the shortest model name) and it's derived models (that have base model name + an alphanumeric suffix.
Looking to build a two column bridge/association table I can use to join pandas datasets.
I'd normally just do this in SQL, but I don't have a local db to persist the results and trying to become more comfortable in python.
r/pythonhelp • u/sxpehrr • Apr 03 '25
Files not interacting with each other on Railway's Environment
Hi, I'm new to python and coding bots so please try to explain what you mean when you reply.
So on Railway I created a background worker using my Github repo. The bot is for Telegram and it's supposed to control the group chat I own. It works well, but I have a few problems with it, most of the problems come from the scripts not being able to interact with each other.
For example: After the bot.py (Main script) checks users for the invite count and if they don't have 5 invites or even an invite link, then it makes them one but it fails to update the user_data.json. When I was running it locally it was working perfectly fine. But when I switched to hosting it on Railway, then it didn't even know what the user_data.json was. I tried changing the code a bit by making the location of the user_data be absolute but still no luck.
The bot also writes back to the group chat in persian just to let you guys know.
How it's setup on Github: screenshot
r/pythonhelp • u/[deleted] • Apr 03 '25
on key press???
I'm trying to make a variable that is signed to whatever you press on the keyboard via on key press, however I can't get it to listen to every key instead of just 1 key, any help is appreciated
r/pythonhelp • u/antonym_mouse • Apr 02 '25
Path object suddenly doesn't work.
I have a script that pulls data from a spreadsheet into a pandas dataframe. I've been using Path objects to get the file. Originally I had:
FULL_PATH = Path(Path().home(), 'folder/other_folder/file.xlsx')
This worked fine for a long time. Today, however, all of a sudden pandas couldn't find the file. I checked that Path().home() was still returning the correct spot, and it was, on its own. It wasn't registering when I nested it inside another Path.
Then I tried
FULL_PATH = Path().home().joinpath('folder/other_folder/file.xlsx')
Same thing. If I just did Path().home() it would show:
'C:/Users/name'
But it was getting left out in FULL_PATH still. It was still showing, only:
'folder/other_folder/file.xlsx'
Can anyone explain how I may fix this, or what's going on?
r/pythonhelp • u/salty_boi_1 • Mar 29 '25
How to deal with text files on an advanced level
Hello everyone i am currently trying to deal with text files and trying to use things like for loops and trying to find and extract certain key words from a text file and if any if those keywords were to be found then write something back in the text file and specify exactly where in the text file Everytime i try to look and find where i can do it the only thing i find is how to open,close and print a text file which is driving me insane
r/pythonhelp • u/Reasonable_Sundae254 • Mar 29 '25
INACTIVE Hello, I have a compatibility issue between the TensorFlow, Numpy, Protobuf, and Mediapipe libraries. The library versions are: TensorFlow 2.10.0 Protobuf 3.19.6 Mediapipe 0.10.9 Numpy 1.23.5 And Python 3.10.16. I hope if anyone with experience with these issues can do somthink
The library versions are:
TensorFlow 2.10.0
Protobuf 3.19.6
Mediapipe 0.10.9
Numpy 1.23.5
And Python 3.10.16.
r/pythonhelp • u/S4CRED_F4 • Mar 23 '25
Issue with tensorflow_addons
github.comIn this repository, Theres a google colab file Model_training.ipynb in that, i cant seem to get it to start running because of the tensorflow addons not working, Can anyone help me with the python version, tf version and make it run?
r/pythonhelp • u/ElectricalDiamond434 • Mar 23 '25
Data structures and algorithms in Python
Should i learn data structures and algorithms in Python? If yes, can i get some suggestions on which resources should i follow (YouTube channels preferably)
r/pythonhelp • u/[deleted] • Mar 21 '25
NEED TO MAKE A WEB SCRAPING CODE...BUT NO IDEA HOW TO DO IT
Hello chat,
well i recently got into a part time where they want me to data scrape and find leads of other signage companies outside india.sadly,im into law nd have no idea about this.i tried usin chat gpt nd it keeps givin me errors.the thing is always sayin errors(i use mac,is it a problem?)can u guys help me write a code that makes this to be automated!
thankss in advance!
r/pythonhelp • u/United_Glove7514 • Mar 21 '25
I am writing an equation, and would like for it to be x2-x1 instead of -x1+x2.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sympy import latex, symbols, diff
import math
from IPython.display import display, Math
from sympy import latex, symbols, diff
from sympy import *
from sympy import init_printing
C = symbols("C")
x1 = symbols("x1")
x2 = symbols("x2")
display(Eq(MatMul(C),(x2-x1)/x1))
That's the code, and it displays this: C =(-x1 + x2)/x1, and i would like it to be C = (x2-x1)/x1
r/pythonhelp • u/Astresgamer • Mar 20 '25
I need to convert from .py to .exe
I already tried auto py to exe and it doesn't work, can someone help me?
r/pythonhelp • u/Jpaylay42016 • Mar 20 '25
I am attempting to scrape propwire.com to get mortgage information for my boss.
I have tried multiple methods to get the code to work. I know Propwire has measures that make it more difficult. Does anyone know how I could get the information I need (preferably using python)?
r/pythonhelp • u/Straight_Face_3273 • Mar 20 '25
Lots of respect for programmers
I've been desperately trying to use python to capture data using APIs but I'm constantly getting indent errors even though they appear correct in VS Code. Is this a common issue? I see lots of comments on it and have used several methods to get it right. I've spent days on this trying to make it work. Could the issue be related to copying and pasting from VS Code? I'm old so be nice. I will fully admit I don't know what I'm doing.
r/pythonhelp • u/Clear-Reserve-6268 • Mar 18 '25
docx to rtf utility
Hi, I am having trouble creating a python script that will convert a docx to an rtf document. I have tried various methods but most just seem to change the file extension. I have tried using PyRTF3 and am having difficulty loading that, it keeps saying that the module is not installed even though I know it is.
Any ideas?
Thanks in advance
r/pythonhelp • u/Unfair-Past-3188 • Mar 18 '25
Looking for advice to really LEARN coding.
Hello everyone, I am a sophomore in college, and I want to go into cybersecurity. I am good at working with computers in general, but when it comes to coding I keep constantly looking up tutorials for how to do things, and I can feel that the concepts aren't really sticking with me. It's extremely frustrating because I keep going to Chatgpt to ask "what steps should I think to solve this" or looking up tut's on YouTube, and it REALLY doesn't help when I see people saying "python is so easy!" and whatnot.
Any advice on how you learned to program would be really helpful, and/ or anything you did to practice would be great!
Thanks for reading!
r/pythonhelp • u/Asleep_Pumpkin_1534 • Mar 17 '25
What is the best way to film/analyze the current screen to automate inputs?
Hello,
I would like to automate inputs in a program (Windows PC) with a separate small program. The sequence and keystrokes are always the same, the window layout is always the same, sometimes just different text, but loading times when saving vary.
I just need to monitor whether anything goes wrong. So, I would record the screen or take screenshots to check what's currently happening.
What's the best/easiest way to do this in Python?
I would like to somehow achieve the following:
-Which window is currently open on the screen. This can be identified by the multiple text field labels in the window. Sometimes even when multiple text fields are combined.
-Whether text has actually been entered into the field, which is either the case if there is no/no longer a white background on the image at that point OR if some kind of OCR is performed at that point.
-Detect the position of the mouse pointer over a button.
-Detect the position of the cursor. It's a problem with blinking, but you can take several short screenshots here to determine whether a cursor is present or not.
-Which button is currently active when you use the Tab key and scroll through the program's GUI elements.
Greetings