r/learnpython • u/FuzzyEmployment264 • Sep 07 '26
python online course
name one best python course on internet
r/learnpython • u/FuzzyEmployment264 • Sep 07 '26
name one best python course on internet
r/learnpython • u/live_ant718 • Sep 07 '26
I have a question. Like when we have a program that takes input, so when the program reaches the input line, it stops and asks for input, right? So then AFTER the input is entered, if the compiler runs into a bug, it stops and throws an error message. How can I stop this? Like how can I make the issues appear beforehand so that I can fix them before running? Are there any settings or tools for this problem?
Please tell me.
r/learnpython • u/Strict-Chicken-1697 • Sep 07 '26
How can I learn to code in Python if I have no experience? I tried to do something myself, but where should I start? I tried to use Pycharm, but I have a lot of errors in the code, and I don’t really know English (I’m writing this post through a translator). I want to start making websites in Python, but I’m 14 and have no experience. Where should I start? My text is not ai I'm just a foreigner without knowledge of English
r/learnpython • u/Ok_Breath_7590 • Sep 07 '26
r/learnpython • u/chronicomplainer2 • Sep 07 '26
it seemed to work when i tested it but i did it myself and just stuck in things that i read abt and thought pertained to the project i was trying to create, it is supposed to allow multiple people to stay connected at the same time but im wondering if there's some logic error anywhere that i might not have picked on, or if the code is genuinely robust enough to accommodate multiple connections. i didn't need to use any threading at all in the end, which i found a bit strange, and also im a beginner in python so i was hoping if people could point out some potential issues, thanks!
import socket
import select
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("localhost", 80))
s.listen()
def send_response(sock, message):
"""Sends an encoded response."""
sock.sendall(message.encode("ISO-8859-1"))
def handle_packets(queue_dictionary):
"""Performs certain actions based on packet."""
for soc in queue_dictionary:
if not queue_dictionary[soc]:
continue
#take the first item from the queue
packet = queue_dictionary[soc].pop(0)
#send specific responses based on the type of data sent
if packet == b"Hello\r\n\r\n":
send_response(soc, "Message received successfully. Hiiii!!!!\r\n\r\n")
elif packet == b"Ignore\r\n\r\n":
send_response(soc, "Message received successfully. Hey, don't leave me hanging...\r\n\r\n")
elif packet == b"Hug\r\n\r\n":
send_response(soc, "Message received successfully. *Hugs back*\r\n\r\n")
elif packet == b"Slap\r\n\r\n":
send_response(soc, "Message received successfully. OW! That hurt!\r\n\r\n")
elif packet == b"Goodbye\r\n\r\n":
send_response(soc, "Message received successfully. Goodbye!!! Do come back again!! :)\r\n\r\n")
else:
send_response(soc, "Message received successfully.\r\n\r\n")
#create a list of connected sockets, satrting wtih listening soccket so accept
#doesn't block
#dictionary with buffer per socket and also list which was initially queue
read_set = [s]
buffer_dict = {}
queue_dict = {}
while True:
ready_to_read, _, _ = select.select(read_set, [], [])
print("Creating a list of sockets currently sending data...")
#for all sockets that are ready to read
for sock in ready_to_read:
#if the socket is a listener
if sock == read_set[0]:
#accept a new connection
new_conn = s.accept()
print("Accepting connection...")
new_socket = new_conn[0]
#initialise buffer and queue for new socket
buffer_dict[new_socket] = b""
queue_dict[new_socket] = []
print("Adding socket to buffer and queue dictionaries...")
#add the new socket to the set
read_set.append(new_socket)
print("read_set: " + str(read_set))
print("Adding socket to read_set...")
packet = "empty"
continue
else:
#recieves data until full packet
while True:
data = sock.recv(4096)
print("Receiving data...")
if not data:
print("Connection closed.")
break
buffer_dict[sock] += data
if b"\r\n\r\n" in buffer_dict[sock]:
delimiter_index = buffer_dict[sock].find(b"\r\n\r\n")
packet = buffer_dict[sock][:delimiter_index+4]
buffer_dict[sock] = buffer_dict[sock][delimiter_index+4:]
break
if packet:
queue_dict[sock].append(packet)
print("Adding a packet to the queue...")
else:
x = input("No packet returned.")
#run packet handler code based on nature of packet for socket
if packet != "empty":
print("Sending response...")
handle_packets(queue_dict)
print("Response should send now.")
new_socket.close()
s.close()r/learnpython • u/AutoModerator • Sep 07 '26
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/Healthy-Departure961 • Sep 07 '26
from datetime import *
year = int(input("Enter the Year:- "))
month = int(input("Enter The Month:- "))
day = int(input("Enter The Day:- "))
x = date(year,month,day)
validity = int(input('Enter the days of validity')) expiry = x + validity print(expiry)
I want to add days in this but i don't know how ,I even tried to adding manually but gives me error unsupported oparand + in datetie.datetime class something
r/learnpython • u/Heavy-Notice6820 • Sep 07 '26
Hi everyone, recently joined college this month as a cse fresher nd with no coding exp so now dont know from where to start from seniors do help plssssss
thought of starting python but bit confused few things to ask
What should a complete beginner in CSE start learning first?
Should I start with Python? will it be a sensible decision
What topics should I focus on initially?
Are there any good YouTube channels or should i go for courses, or other resources you would recommend?
Is there a particular roadmap I should follow during my first year?
What should I avoid wasting time on as a beginner?
Would really appreciate any advice from seniors or people who have been in a similar situation
plsssssss do helpppppp need advice dms open
r/learnpython • u/Altruistic_Big9806 • Sep 07 '26
Hi everyone, I'm new to python and I'm building a project to hone my skill, and I came to a halt in this part. When I do if user_input == 'q':, it works and breaks the loop just fine, since i dont wanna make the exit just single letter so even if the user input words like 'quit' 'q' or 'QUIT' it will exit the loop, I tried a different approach like doing user_input == ['q', 'quit']: and another approach where i declared a variable first exit_word = ['q', 'quit'] then
user_input == exit_word: none of this breaks the loop it just goes back to the input prompt heres my work below:
import random
user = 0
computer = 0
options = ["rock" , "paper", "scissors"]
while True:
user_input = input("Rock/Paper/Scissors and Q for Quit: ").lower()
if user_input == 'q'
break
if user_input not in options:
continue
random_num = random.randint(0, 2)
computer_pick = options[random_num]
print('Computer picked', computer_pick + ".")
if user_input == 'rock' and computer_pick == 'scissors':
print('You won!')
user += 1
elif user_input == 'paper' and computer_pick == 'rock':
print('You won!')
user += 1
elif user_input == 'scissors' and computer_pick == 'paper':
print('You won!')
user += 1
else:
print('You lost!')
computer += 1
print("The user won", user, "times")
print("The computer won", computer, "times")
print('Goodbye!')
r/learnpython • u/live_ant718 • Sep 06 '26
Hello guys. So I have created a password guesser game with direct comparison (i.e. if guess == correct_password:) but I want to use different methods for comparison. What techniques can I use? Here is the code-
```python
password = "Random_pass_123"
tries = 0
while tries < 3:
guess = input("Enter the password: ")
if guess == password:
print("Admin access granted.")
break
else:
print("Invalid credentials entered. Please try again")
tries += 1
if tries == 3:
print("Number of tries exceeded. Access denied")
```
PS- Is this the right way to paste code? I'm new so I'm not sure.
r/learnpython • u/live_ant718 • Sep 06 '26
Hello guys. So I saw in a course that most people define variables like
x = 1
y = 2
and so on. But I also saw that variables can be defined like x = 1; y = 2;
but haven't ever seen this in practice. Why so? Please tell me
r/learnpython • u/Party-Mechanic7635 • Sep 06 '26
Quem já viu aqueles sites que mostra os últimos seguindo e seguidores do Instagram, aquilo é alguma api? Alguém sabe como funciona?
r/learnpython • u/EasternPool3120 • Sep 05 '26
I have finished all my python basics and I want to progress now to building gui programs. Should I use PySide6 or Kivy? If I should use something other than these two what should it be? i personally don't mind it being that complex if it's fast and powerful :)
r/learnpython • u/MustaKotka • Sep 05 '26
TL;DR: Tips for someone who wants to make a very old school text-tile-combat based game?
Let's outline the basic concept of the game.
There are four kinds of NPCs:
I've got some experience with Python and it's not like I'm new to this but something I'm struggling with is the world generation. My idea was to have hexagonal tiles (think Carcassonne but hexagonal) where each tile has 6 map connections and each tile has randomised entities and/or functionality.
This is not what the map will look to the player, this is just my draft of what the map connections / tilesystem could look like. Maybe this could be a minimap of sorts...
_____/ 18 _______/ 8 _____
\ / \ /
17 _______/ 1 _______/ 9
/ \ / \
_____/ 6 _______/ 2 _____
\ / \ /
16 _______/ 0 _______/ 10
/ \ town / \
_____/ 5 _______/ 3 _____
\ / \ /
15 _______/ 4 _______/ 11
/ \ / \
_____/ 14 _______/ 12 _____
\ / \ /So I was thinking about displaying just a single tile and have the tile numbers spiral outwards. The benefit is that I can keep track of tiles that have been generated and I know their position and connections without having a complicated internal lookup table of any kind, really. Tile 0 is always origo, tiles 1 to 6 are nearest to origo, tiles 7 to 18 are the second "ring" and so forth. For each 6n tiles, where n is the "ring" I know I've jumped onto a new "ring" and can calculate the map connections easily, because the number of tiles is very regular. Additionally I can label the "rings" as tiers where the difficulty increases every time you step out to a new "ring".
Reason why I'm outlining this specifically is because I was wondering if there are cleverer ways to handle this. Other than what I've presented here. I have no clue how real games handle map connections.
For inventory it's just a basic slot-by-slot box "sword equipped", "sword in bag". I'm thinking about adopting the classic Diablo style inventory where you have spaces and an item can occupy a particular shape of spaces. A potion is one space, an axe might be four in an L-shape.
If I want to randomise the equipment stats a bit should I think about giving each item a unique integer identifier + stat identifiers? It'd probably be a pain in the butt if my ID was the actual name of the weapon e.g. "Iron Sword". Right?
I'm currently at a stage where I have:
So not very far.
Any tips in general for what kind of pitfalls to avoid?
r/learnpython • u/Gullible_Tower3954 • Sep 05 '26
I’ve been working on a networking project to dive deeper into Python's packet manipulation capabilities.
What My Project Does I forked evillimiter (a Python CLI tool that uses ARP spoofing and tc/iptables to throttle local network bandwidth) to use as a base. The original tool relies on static MAC addresses, which completely breaks tracking when modern iOS/Android devices use MAC Randomization. Instead of using complex/heavy ML for RF signal analysis, I'm modifying the tool to use scapy for passive tracking. The Python script identifies the endpoint based on its DHCP Fingerprint (Option 55 parameter sequence) and mDNS hostname broadcasts. Once recognized, it dynamically updates the ARP spoofing and routing rules to maintain the throttle even when the MAC rotates.
Target Audience This is a learning/experimental project aimed at Python learners, networking enthusiasts, and homelab tinkerers who want to understand low-level packet sniffing and traffic shaping using Python. It's a toy project and not meant for production environments.
Comparison Compared to the original evillimiter, this fork specifically tackles the modern challenge of MAC randomization without breaking the core logic. While massive frameworks like bettercap can do packet inspection, this project aims to be a very lightweight, single-purpose Python script focused purely on dynamic bandwidth throttling without heavy dependencies.
Transparency note: I'm still getting the hang of low-level networking in Python, so I’ve been leaning on AI to help me structure the Scapy logic and overall architecture.
You can check out the repo here:https://github.com/DavidsonRafaelK/evillimiter
I’d really appreciate some feedback from the Python community:
scapy sniffer in the background for DHCP/mDNS can be resource-heavy. Are there best practices to keep memory usage low when doing long-term sniffing in Python?Thanks!
r/learnpython • u/EnderGem957 • Sep 04 '26
SOLVED!
I'm attempting to make 10 functions, put them all in a list, and then have a for loop go through each element of the list. The list is below.
exercises_list = [exe1(), exe2(), exe3(), exe4(), exe5(), exe6(), exe7(), exe8(), exe9(), exe10()]
When this list is placed beneath (but not apart of) function 10 and before the for loop, the IDE reads it, and immediately starts acting on the list. (e.g. begins to act out exe1() the second it gets to it then moves on to exe2() and so on.) How do I make it so that my list doesn't actually get run until I call for a specific element in the list?
r/learnpython • u/LL_darkstrike29 • Sep 04 '26
Hi, I'm new to this Reddit community. Does anyone know of any online games to learn Python? Thanks!
r/learnpython • u/ChronicOverthinker34 • Sep 05 '26
Did any body used Socratic au method to learn pyhton kr any other programming language? I wanna know the results if it really works
r/learnpython • u/worldvex • Sep 05 '26
I wanted to create a function with while statement that I get 100 random numbers from import random and if there is 1 1 1 is stop took me a while cause I am a beginner and I didn't know most of the things I was gonna used so I learn while , break and != ( not equal to )
I started programming cause I was an introvert and didn't had anything else to do
It took me a while like 1 hour
Made this caused I wanted to generate something closed to gambling
mistake I made
1 using "and" instead of "or " ( yeah dump mistake)
2 using if statement for like 20 minutes until I search how to generate infinity and found out about while statement
My code (man made except for this sing != I used claude for it )
import random
num = random.randint(0 , 30)
print(num)
nu = random.randint(0 , 30)
print(nu)
nm = random.randint(0 , 30)
print(nm)
while num != 1 or nu != 1 or nm != 1 :
print("failed")
num = random.randint(0 , 30)
print(num)
nu = random.randint(0 , 30)
print(nu)
nm = random.randint(0 , 30)
print(nm)
Ai code (claude)
import random
while True:
nums = [random.randint(0, 30) for _ in range(3)]
print(nums)
if all(n == 1 for n in nums):
print("Success! Got [1, 1, 1]")
break
print("failed")
!!!
Sorry for my English it is not my first language
Second I don't know python that good so anything I mispronounced like statement or syntax my bd
r/learnpython • u/Mo_Reda_1 • Sep 05 '26
I have just finished week1 in cs50 python course and since i'm learning python for AI Agents Engineering i thought it would be cool to practice this content with a relevant project .
so i made a simple AI agents execution getaway program that routes the incoming tasks based on tokens , creativity and risk score .
I tried to use most of what i learned in this lecture as possible like 'match' for matching the tool with appropriate model , or 'return' as guard clauses for the safety check at the beginning .
here is the code link :
https://gist.github.com/mohamed-reda-ai/a10a1e9311d94316ffa31c00de005226
I know it's not a big brilliant thing i want just to practice the concepts i learned .
If you have any feedback about the architecture of the code or you think there is a better way to do something in it , i'd appreciate this .
r/learnpython • u/SmeckoGeck • Sep 04 '26
I'm trying to compile something, but it requires the use of py instead of python.
The thing is, whenever I try to use py, the command line will just say No installed Python found! This doesn't happen when I use python for calling an action.
I wanted to make sure py is in my PATH, so doing where py does show the path to py.exe. I know that py does exist in PATH, but it just doesn't work when trying to use it compared to using python.
Uninstalling and reinstalling Python doesn't seem to do anything new, so what should I do?
I should probably mention that I'm using Wine on MacOS because compiling on MacOS seems to require specific Windows executable files, and I need Wine for that.
r/learnpython • u/MoreScorpion289 • Sep 05 '26
Hello, this is an update to the post I made yesterday.
All 3 copy-pasted validation blocks are now 1 function called 3 times. It takes the category, password (string), a label, and returns True or False. The checks aren't sitting behind a door that gets unlocked only if the last check is met, all error messages show up at once instead of one at a time. I removed the outdated variables that had no use.
I took u/jammin-john's recommendation of showing all error messages at once.
Also want to include u/danielroseman's push for me to learn functions. They work really well, I haven't learned "for loops" yet but they are next in line.
I used AI (Claude) as a tutor to understand concepts and point me toward my own bugs, but I wrote and debugged every line myself. I'm learning how to code through the MOOC.
Here is the GitHub link to my program: link
r/learnpython • u/Upper-Quail-205 • Sep 05 '26
Hola a todos!vivo en Venezuela y estoy muy entusiasmado aprendiendo programación con Python. Actualmente estoy trabajando con una laptop muy limitada (2 GB de RAM) y un entorno liviano usando Sublime Text y la consola.
Mi meta es dominar las bases de Python para poder construir mis propios proyectos y, en el futuro, abrirme campo laboral en el área tecnológica. Sin embargo, el estado de mi equipo actual y la falta de memoria me dificultan seguir avanzando con fluidez en la práctica.
Escribo a esta comunidad para preguntar si alguien tiene una laptop vieja, reacondicionada o en desuso (o piezas compatibles) que ya no utilice y esté dispuesto a donar o vender a muy bajo costo. Cualquier equipo capaz de correr un entorno de desarrollo básico me sería de gigante utilidad.
Si alguien está en disposición de apoyarme, me comprometo a cubrir o gestionar el tema del envío a través de un casillero internacional hacia Venezuela.
Agradezco de antemano cualquier consejo, orientación o ayuda que me puedan brindar. ¡Muchas gracias por su tiempo!
r/learnpython • u/Tough_Duty_9061 • Sep 05 '26
I am a beginner in python code and currently learning how to make chatbots using api keys but i just cant do it. I tried open ai but it requires credits i tried gemini but due to a latest change in api keys from AI to AQ it says model not found i tried groq but it said the same thing i checked my code myself and with cluade gemini and codex but couldnt find the issue can u help me make my first chatbot pls guys 🙏can u tell a few 'free api keys' if there is ....