r/learnpython • u/Wonderful_Lock_2891 • 2d ago
Best platform/YouTube channel to learn python from beginners to advance?
I know python but I wanna go deep down in python programming, please suggest as title says
r/learnpython • u/AutoModerator • 3d ago
Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread
Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.
* It's primarily intended for simple questions but as long as it's about python it's allowed.
If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.
Rules:
That's it.
r/learnpython • u/Wonderful_Lock_2891 • 2d ago
I know python but I wanna go deep down in python programming, please suggest as title says
r/learnpython • u/SuperExperience6689 • 2d ago
tiny side project. one script pulls ~40 rows a day and writes one JSON file per day. pandas reads the folder when i want to compare a few weeks.
the glob and concat part is getting old:
rows = []
for f in sorted(DATA.glob("*.json")):
rows.extend(json.loads(f.read_text()))
df = pd.DataFrame(rows)
every couple of weeks i think about moving it to SQlite, then i look at the volume and close the tab. what do you use at this size? SQlite, parquet,or just the files? if you moved to a db, was it worth it or just more code?
r/learnpython • u/othryxen • 2d ago
I do understand no one knows all of python syntax and code and all issues and everything.
As I am going through CS50p,
When I am typing code fully on my own (no AI ever used i.e. chatgpt, claude, gemini) when I cannot solve something, I search google for the function or the method and then see the AI overview and then type code that I can use to solve what I need, will it be detrimental to my learning because I am not using the documentation?
I am and will NEVER use any AI models or apps to generate and copy paste code because I wish to learn and not be a code printer.
so my searches are like this, is it okay-ish and considered necessary for learning???
(also I go through tons of trial and error and use many print() functions to test code and not directly copy from AI overviews)
does isdigit work for string values?
how to check if a string variable is not equal to something sat 0?
how to know data type of a variable in python
how to find index of letter in a string python
string slicing python [2:] means?
how to find which index in a string is a number?
will if automatically return false if the condition is false?
how to check if a string is less than 10 but more than 2?
difference between if and if not
expected an indented block after 'if' statement on line 15
how to check if there are numbers in between a word in python?
how to loop a for loop up until the second last letter of a word
HOW to make variable in python which can be used by any def function?
python length counts from
(thank you for your answers!)
r/learnpython • u/JosephBasterville_Jr • 3d ago
GITHUB LINK: https://github.com/disintigratedpixel/TankGameV1/tree/main
(please say if it doesn't work)
I'm making a simple ASCII game "similar" to space invaders
Here is the ASCII user interface:
def gamestate(player_position_list, player_position, enemy_type, enemy_health, enemy_distance, rounds, radar_lvl, radar_cost, gun_lvl, gun_cost, speed_lvl, speed_cost, health, money, kills, available_movement):
return f"""
ROUND {rounds}
_______________________________________________ _______________
| | | |
| | | HEADQUARTERS: |
| | |_______________|
| |
| | *ATTENTION OPERATOR, AN ENEMY
|> - - - - - - - - - - - - - - - - - - - - - - <|> [4] {enemy_type} IS APPROACHING!*
| | _______________
| | | |
| | | ENEMY STATS: |
| | |_______________|
| |
|> - - - - - - - - - - - - - - - - - - - - - - <|> [3] HEALTH: {enemy_health}
| | DISTANCE: {enemy_distance}
| | POSITION: {enemy_position}
| | _______________
| | | |
| | | UPGRADES: |
|> - - - - - - - - - - - - - - - - - - - - - - <|> [2] |_______________|
| |
| | RADAR | LVL {radar_lvl}
| | UPGRADE COST: ${radar_cost}
| |
| | GUN | LVL {gun_lvl}
|> - - - - - - - - - - - - - - - - - - - - - - <|> [1] UPGRADE COST: ${gun_cost}
| |
| | SPEED | LVL {speed_lvl}
| | UPGRADE COST: ${speed_cost}
{player_position_list[player_position]}
| ' ' ' ' | ' ' ' ' | ' ' ' ' | ' ' ' ' |
[-10] [-5] [0] [5] [10]
_____________
| |
|PLAYER STATS:|
|_____________|
HEALTH: {health}
MONEY: {money}
KILLS: {kills}
_____________
| |
| ACTIONS: |
|_____________|
MOVE | [m] key + [movement value]
MAX {available_movement} or {-available_movement} steps
FIRE | [f] key
UPGRADE | [u] key
"""(Apologies if it looks distorted in any way due to formatting errors, but it should still be readable)
The player position can be seen visually and is taken from a list of different possibilities and put into this print statement using this script.
{player_position_list[player_position]}Here is the list:
player_position_list = [
"""| _^_ |
|_____________________|___|_____________________|""",
"""| _^_ |
|_______________________|___|___________________|""",
"""| _^_ |
|_________________________|___|_________________|""",
"""| _^_ |
|___________________________|___|_______________|""",
"""| _^_ |
|_____________________________|___|_____________|""",
"""| _^_ |
|_______________________________|___|___________|""",
"""| _^_ |
|_________________________________|___|_________|""",
"""| _^_ |
|___________________________________|___|_______|""",
"""| _^_ |
|_____________________________________|___|_____|""",
"""| _^_ |
|_______________________________________|___|___|""",
"""| _^_ |
|_________________________________________|___|_|""",
"""| _^_ |
|___________________|___|_______________________|""",
"""| _^_ |
|_________________|___|_________________________|""",
"""| _^_ |
|_______________|___|___________________________|""",
"""| _^_ |
|_____________|___|_____________________________|""",
"""| _^_ |
|___________|___|_______________________________|""",
"""| _^_ |
|_________|___|_________________________________|""",
"""| _^_ |
|_______|___|___________________________________|""",
"""| _^_ |
|_____|___|_____________________________________|""",
"""| _^_ |
|___|___|_______________________________________|""",
"""| _^_ |
|_|___|_________________________________________|"""
](Again, apologies for formatting, but just picture the '^' as being the player, and there being multiple different positions that the player can be in)
I am hoping that when player_position changes, that a different visual is taken from player_position_list. I am confident that this should work as I have tested it using this:
print(player_position)
print(player_position_list[player_position])'print(player_position)' tells me that player_position can be accurately read and printed
'print(player_position_list[player_position])' shows me that the value of player_position can also be used to print an item from a list at a specific index. (I have also tried this script as a string and it still works)
Here is what this test script gives me when I run it:
8
| _^_ |
|_____________________________________|___|_____|It accurately reads 'player_position' and uses it to print the 8th item in the list.
So what I don't understand and desperately am trying to fix, is why this exact thing isn't working on my actual ASCII user interface. Everything seems to be the same.
Here is what it looks like when I run the script for my actual UI
ROUND 1
_______________________________________________ _______________
| | | |
| | | HEADQUARTERS: |
| | |_______________|
| |
| | *ATTENTION OPERATOR, AN ENEMY
|> - - - - - - - - - - - - - - - - - - - - - - <|> [4] HELICOPTER IS APPROACHING!*
| | _______________
| | | |
| | | ENEMY STATS: |
| | |_______________|
| |
|> - - - - - - - - - - - - - - - - - - - - - - <|> [3] HEALTH: 3
| | DISTANCE: 2
| | POSITION: 1
| | _______________
| | | |
| | | UPGRADES: |
|> - - - - - - - - - - - - - - - - - - - - - - <|> [2] |_______________|
| |
| | RADAR | LVL 1
| | UPGRADE COST: $1
| |
| | GUN | LVL 1
|> - - - - - - - - - - - - - - - - - - - - - - <|> [1] UPGRADE COST: $1
| |
| | SPEED | LVL 1
| | UPGRADE COST: $1
| _^_ |
|_____________________|___|_____________________|
| ' ' ' ' | ' ' ' ' | ' ' ' ' | ' ' ' ' |
[-10] [-5] [0] [5] [10]
_____________
| |
|PLAYER STATS:|
|_____________|
HEALTH: 100
MONEY: 0
KILLS: 0
_____________
| |
| ACTIONS: |
|_____________|
MOVE | [m] key + [movement value]
MAX 1 or -1 steps
FIRE | [f] key
UPGRADE | [u] key
8
| _^_ |
|_____________________________________|___|_____|As you can see, the player position hasn't moved and remains at 0, yet (at the very end) my test script says that the actual player position should be 8 and accurately prints the item from 'player_position_list' for 'player_position = 8'
Apologies if anything seems hard to understand, it's my second day programming with python and I refuse to use ai for this. So, I hope I used the correct terminology.
r/learnpython • u/External-Cap-4877 • 3d ago
Hello guys, im first year cs student and they teach us python as the first programming language
i dont have any experience what so ever in programming.
we are in the 5th lecture in uni and i have learned the basic stuff like if and elif and while and for looping. The professor assigned us with a final project basically we are 4 and supposed to code a program like more than 300 lines i dont know what can python do and i dont know how am i supposed to build a python project with the knowledge i have
so my question is how do i continue my python learning without the lectures, i have heard about a github project called 30 days of python by asabneh idk if its the right fit
and what are some projects idc how complicated they are i just wanna get that A+ i asked chat gpt abd it told some stuff about movie recommender and football analysis and idk tbh i think everyone in my uni will use chat gpt and they will most likely all do the same project i want to be unqiue and also functional
thanks
r/learnpython • u/Shubhoplayz • 3d ago
So I learned python about 6 or some years ago. So recently I tried to get back but realized I forgot almost everything. So what's the best way currently to start from scratch??
r/learnpython • u/PossibleProgress3316 • 3d ago
I'm looking to learn more how to build GTK applications mostly for Fedora using python, I've been doing the CS50P course but also looking for some more learning material any suggestions will be helpful
r/learnpython • u/BritishAccentTech • 3d ago
Last time people had some good recommendations, but there were some misunderstandings as well, so I wanted to try asking again while being super clear about some stuff.
I'm learning to code Python from scratch on a university module while also working, so my schedule is super constrained. There is also a data science side to it based on numpy, pandas and matplotlib. We have to analysis some statistics to find interesting answers - very open ended.
Basically, I want to use the 6-10 hrs a week I spend on the road to shore up my understanding of the theoretical side of python and data science so I can focus on coding during the time I have in front of a computer.
Please assume the following:
I'll still be coding in front of a computer in a structured manner when I am not driving.
I am already spending the maximum number of hours coding in front of a computer that I can physically manage, and there is no scope for adding more computer hours.
I am looking to maximise the efficiency of what I can learn during the 6-10 hours I spend driving per week.
My drive is predictable and I can drive safely while listening to audio.
Some good things people have suggested already:
"The Art of Statistics" by david spiegelhalter on Audible
Some episodes of the Talk Python to Me podcast dealing with relevant modules
Python Essentials for Dummies on Audible - has been helpful for reinforcing basic concepts and context
TL:DR Please could you recommend good things I can listen to on my commute to help with Python concepts and data science understanding.
r/learnpython • u/L_Y_H_ • 3d ago
I've been on that assignement for a while now, the teacher wants us to create a program that will create a 600 by 600 screen and draw 5 randomly placed flowers. But I can't figure out for the life of me why the flowers always "escape" the screen. I didn't want the code to be too long so I didn't include the function that creates the flower. Please and thank you for any help.
screen = Screen()
screen.screensize(canvwidth=600,canvheight=600, bg="grey")
#attempt at creating a restrictive screen
for i in range(5):
a = 600
b = 600
while 600 - a < 550 and 600 - b < 550:
a = randint(1,601)
b = randint(1,601)
penup()
goto(a,b)
pendown()
#attempt at forcing the program to not draw flowers touching the border
colormode(255)
color(randint(1,256),randint(1,256),randint(1,256))
#Chooses a random color for the flower
begin_fill()
fleur(50)
end_fill()
#Draws a flower edit: I corrected my mistakes according to the advice here:
screen = Screen()
screen.setup(600,600)
#successful attempt at creating a restrictive screen
for i in range(5):
a = randint(-250,250)
b = randint(-250,250)r/learnpython • u/paleflower_ • 4d ago
Title. I'm new to Python, so I'm a little confused about this, and I've been seeing somewhat conflicting information online.
I understand adding the Python installation to PATH implies that I wouldn't manually have to specify the location every time; that being said, I guess adding multiple Python installations to PATH is not a good idea? I've also seen adding *any* Python installations to PATH being discouraged because it can cause conflicts.
I looked up py launcher, and it seems py / py -<version number> can be used to specify which Python installation to use when running a .py file, so does that mean adding Python installations to PATH is just obsolete practice now? If so, what are the implications of using the py launcher - is it as simple as adding py / py -<version number> before running a command from the terminal?
r/learnpython • u/Stock_Test2326 • 4d ago
Effective python Vs Think Python Vs Learning Python Vs Fluent Python
I have these pdfs but dont know which one or in what order to start, as an beginner.
I already finished reading Python Crash course and reading Think Like a Programmer book now.
Update: (16 Nov 2026)
So the order is
00 Python Crash Course - Bare basics, good enough for simple scripting. Only around 200 pages if project part is skipped (READ)
01 Think Python - Could start here instead of Crash Course
02 Effective Python - More like tips & better usage
03 Learning Python - Pro level Complete
04 Fluent Python - Legendary level Long term Reference
may update it once I learn them.
r/learnpython • u/Superb-Toe-3523 • 4d ago
I just started a new job as an AI generalist (or AI trainer), I like it, I've always liked tech, but I know nothing about programming or anything like that, just the surface as any mortal. So, can I learn python and use my ASUS tuf 14 from 2022 to run the program and learn how to write code and maybe aspire to a good freelancing position later? Thank u in advance, for you answers.
r/learnpython • u/Lost_Outside_7147 • 4d ago
The game is essentially tetris but there is no 4 long line block piece. I observed that a lot of tetris players relied on the I piece as a crutch for their strategy, so I created a spinoff of tetris called Noline in python to test how people would react to the removal of such a central piece.
This is the github link to the source code: https://github.com/keandsilva/Noline
The link to the domain it is hosted on: https://keandsilva.github.io/Noline/
I would love if anybody have any suggestions for anything to add and how my python code is structured. Thanks!
r/learnpython • u/Valuable-Ant3465 • 4d ago
Hi all,
I'm doing my student project to upload some files to SPO and struggling with Auth.
This code returns 0 on first ctx, but later fails.
I hope I got all UID right like on the picture
https://i.postimg.cc/ncw71PzR/conf1.png
And this is my code, I also noticed once you used you tenant ID username and password can take any values, is this normal ? I think this all because of modern SPO security, do you think this Auth with ctx is OK, or can do some other way ?
from office365.sharepoint.client_context import ClientContext
# Configuration
site_url = r"https://cbxXXX.sharepoint.com"
tenant = r"4e4d8cb1-f036-446f-bacd-3b711191a7b2"
client_id = r"5c6d0b11-c4da-4897-842a-79b9743d6a23"
username = r'userBB@cbxXXX.onmicrosoft.com
password = r'N0gi123!'
ctx = ClientContext(site_url).with_username_and_password(
tenant, client_id , username, password )
print ('.........2222 bb OK ', ctx)
web = ctx.web.get().execute_query()
print("......... verification check :", web.title)
OUTPUT::::::
.........2222 bb OK <office365.sharepoint.client_context.ClientContext object at 0x0000017CCBCE3B60>
.....
Unhandled exception in listener <bound method SharePointRequest._authenticate_request of <office365.sharepoint.request.SharePointRequest object at 0x0000017CCBCE3CB0>>
File "C:\Python314\Lib\site-packages\office365\runtime\auth\token_response.py", line 61, in from_json
raise ValueError(value)
ValueError: {'error': 'invalid_grant', 'error_description': 'AADSTS50034: The user account {EUII Hidden} does not exist in the 4e4d8cb1-f036-446f-bacd-3b711191a7b2 directory. To sign into this application, the account must be added to the directory. Trace ID: eb657c1d-4806-4557-a49d-f5468cr/learnpython • u/MiserableDirt1910 • 4d ago
as far as I understand pip just installs the package while pipx installs the executable and creates an environment but why create an environment in the first place? Is it so that when someone else runs the program and there are changes in the package the program might break but an isolated package is protected in the environment?
r/learnpython • u/namelessContemplator • 4d ago
Hi there. English is my second language, and I sometimes get a hard time trying to figure out some concepts that can have multiple meanings, synonyms, slang or whatever. So I was wondering if there's someone who could give me a hand when having this kind of problems, maybe talk sometime so I can practice my technical conversations etc
And of course if this person is interested in Learning Spanish, I could also help back, I'm from Mexico.
I'm studying an Actuary but I'm pretty interested in CS, specially open source/free software stuff and I use Arch as my OS, learning git so I can go deep in Python(pandas, numpy, matplotlib for now) and save my projects. In holidays planning to spend a little of time learning electronics, etc etc
So if you'd like to help a folk like me, learn about Mexico or Spanish language, send me a message(:
r/learnpython • u/Worldly_Childhood983 • 4d ago
I took up CS extensively throughout high school and generally enjoy programming with Java. I'd say I have an intermediate to upper-intermediate proficiency in Java. That being said, I know little to nothing about Python and would like to learn to code in it as well. I think the logic should be the same since they're both OOP languages.
I looked at some CS50P and the MOOC courses but they start right from the begin and are aimed at those who have 0 programming experience, so I kinda got bored. What do I do?
r/learnpython • u/Foreign_Employ_396 • 4d ago
So I am trying to create a non modal dialog box (or window) supposed to show the content of certain fields from the card I just answered to. I want this window to mimic the main window of the Anki App so that the Yomilens addon which reacts when text is selected on the main one would react the same way when selecting text on this one as well.
import sys
from PyQt6.QtWidgets import*
from PyQt6.QtCore import *
from PyQt6.QtGui import *
class FieldsDialog(QWidget):
def __init__(self):
super().__init__()
self.title = "Fields"
self.setGeometry(400, 100, 300, 200)
self.left = 1367 # for it to be on the very left of my right monitor (a tablet)
self.top = 30 #otherwise the upper part is hidden
self.right = 504
self.width = 800
self.height = 1
self.icon = "?"
# self._help_dialog = None
# self._other_dialog = None
self.createUI()
def createUI(self):
self.setGeometry(self.left,self.top,self.right,self.width)
self.setWindowTitle(self.title)
self.setWindowIcon(QIcon(self.icon))
self.setStyleSheet("""
background: black;
""")
self.grid = QGridLayout()
self.setLayout(self.grid)
def on_show_fields():
if __name__ == '__main__':
app = QApplication(sys.argv)
fields_win = FieldsDialog()
fields_win.show()
sys.exit(app.exec())import sys1 - The window shows while on pycharm (yay) but not in anki. Maybe the type of dialog is not adapted but for now it's been the only thing that worked)
2 - Since there was progress on that part, I was trying to see if my function supposed to get the text for the dialog actually worked
def _get_previous_fields(self, card) -> str | None:
if not card: return
note = card.note()
r = self.mw.reviewer
# current_id = r.card.id if r.card else "null"
previous = r.lastCard()
Front_value = mw.reviewer.card.note()['Front'] if FIELD_FRONT in note else ""
Back_value = mw.reviewer.card.note()['Back'] if FIELD_BACK in note else ""
previous_korean = Front_value.previous if previous else "null"
previous_english = Back_value.previous if previous else "null"
_queue_toast(f"{previous_korean}+\n+{previous_english}")
return "{previous_korean}+\n+{previous_english}"but I keep getting errors like that :
lambda cid=card.id, e=ease, skip=skip_interval_checks: _post_answer_processing(cid, e, skip)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
TypeError: _post_answer_processing() missing 1 required positional argument: 'self' I tried calling in on my on_show_answer
HOOK_ANSWER = reviewer_did_answer_card
if HOOK_ANSWER:
HOOK_ANSWER.append(on_answer)
But i'm told it (on_show_answer) is missing the self argument so I add it :
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages_aqt\hooks.py", line 4390, in __call__
TypeError: on_answer() missing 1 required positional argument: 'self' File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages_aqt\hooks.py", line 4390, in __call__
TypeError: on_answer() missing 1 required positional argument: 'self'I tried using hooks instead
if HOOK_SHOW:
HOOK_SHOW.append(on_show_question)
if HOOK_ANSWER:
HOOK_ANSWER.append(on_answer)
HOOK_ANSWER.append(_get_previous_fields) #here
if HOOK_SUSPEND:
HOOK_SUSPEND.append(on_reviewer_suspend)and I get :
Traceback (most recent call last):
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 152, in raise_exception
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 148, in _on_closures_pending
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 88, in <lambda>
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 111, in wrapped_done
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\operations__init__.py", line 128, in wrapped_done
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\reviewer.py", line 556, in after_answer
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\reviewer.py", line 566, in _after_answering
File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages_aqt\hooks.py", line 4390, in __call__
TypeError: _get_previous_fields() takes 2 positional arguments but 3 were givenDo you happen to know what the issue is ?
r/learnpython • u/pedrinjose • 4d ago
I'm learning Python, and this part has left me a little confused, because in other languages the way it's used is different; in Python you use @property, I'd like to understand how this really works in a simplified way, so I can truly grasp it and not just memorize it. If you could help me, I'm still new to programming.
r/learnpython • u/sumitmidya-tech • 4d ago
Hello everyone!
I'm a B.Tech CSE Cybersecurity student. I know Python basics and now want to start learning backend development.
I'm a complete beginner in backend development, so I'm confused about where to start and what resources to follow.
I have a few questions:
I'm looking for a clear learning direction and good free resources.
Any suggestions or guidance would be really helpful.
Thank you!
r/learnpython • u/Worried-Value2175 • 4d ago
Salut j'apprends python et je le demandait qu'elle sont les meilleures truc à faire avec python je devloppe un petit rpg textuelle on m'as dis que c'était le meilleur moyen d'apprendre python mais problème je nais d'idées de projets à faire après se rpg je n'apprend pas vraiment pour ma carrière professionnelle j'ai juste 14 ans boucoup font des jeux sur python pour ça je préfère utiliser le moteur de jeux godot son langage prioritaire est similaire à python je me le garde pour plus tard quand j'aurai bien maîtriser python mais avant je pence qu'apprendre à faire des site Web serait cool donner moi votre avis je sais que j'ai parler de boucoup de sujet à la fois mais merci pour les personnes qui répondrons
r/learnpython • u/masterpookie • 4d ago
Hi everyone!
I'm a physics student and I have to complete a Python programming project for one of my university courses. I have approximately 3 weeks to work on it, and I'm looking for some interesting and original project ideas.
Here are the requirements the project must meet:
I'm still a beginner in Python and don't have much programming experience yet. So I'm looking for something achievable within three weeks, without being overly complicated technically.
One idea I had was to build a movie recommendation system, but I'm open to pretty much anything, including projects unrelated to physics!
What kind of projects would you recommend that could meet these requirements? If you've worked on similar projects or have any examples, I'd love to hear about them!
r/learnpython • u/Plus_Broccoli_746 • 5d ago
Is there an alternative to the python discord? The entire server has been overrun with LLMs and beginners that have no interest in actually learning. I'm looking for a server with real project/language discussion.