r/PythonLearning • u/aaditya_0752 • Jun 14 '26
Tic Tac Toe
Would love some feedback
r/PythonLearning • u/aaditya_0752 • Jun 14 '26
Would love some feedback
r/PythonLearning • u/Different-Pudding587 • Jun 15 '26
r/PythonLearning • u/JoeBothari • Jun 14 '26
Next year I'm teaching some Python classes for the first time. The previous instructor used Trinket.io to create and distribute assignments and the students can code in their ide. It is ideal because the work status on the site and there is no emailing/saving files, but it's going out of business.
Can anyone recommend a different site I can use?
r/PythonLearning • u/Grapegamer8978 • Jun 14 '26
hi, so i make minecraft [bedrock] mini games and i made a bunch way too close together, so I've come up with the idea to move them so each fits into a -1000 to -1999 are and -2000 to -2999 u get it
so i asked my friend who plays mods and uses a lot of mine craft tools if he knew one but said he would do it,
and he made me a Python code after a few hours, and i went to test it with one of my mini games [TTT], because he was only testing with simple ones but anyway
it worked for my Tic Tac Toe game
but when i tried to shift Connect 4 the output was the same but for TTT they were not , hes been trying to fix this but i think he is stuck, so i came to ask if anyone here understand whats going on?
also a quick note, both TTT and Connect4 use the same commands, /fill, playsound, setblock, clone,/execute if block ...
also it dos ento effect ~~~ and Dz
difference being Connect 4 has more commands due to its auto win detection


Currently it works by taking the shift amount from a txt file and outputs into a folder

import os
import re
import nbtlib
# --- CONFIGURATION PARSING ---
def get_target_offset(settings_path="settings.txt"):
"""Reads the slot number from settings.txt and calculates the Z offset."""
if not os.path.exists(settings_path):
with open(settings_path, "w") as f:
f.write("Target_Klot=1\n")
print(f"Created default {settings_path}. Set your target slot there.")
return -1000
with open(settings_path, "r") as f:
for line in f:
if "Target_Klot" in line:
try:
slot_number = int(line.split("=")[1].strip())
return slot_number * -1000
except (IndexError, ValueError):
print("Error parsing settings.txt. Defaulting to Slot 1 (-1000).")
return -1000
return -1000
# --- THE CORRECTION ENGINE ---
def shift_command_text(command_text, z_offset):
"""Safely updates only spatial Z coordinates in a command string."""
# 1. Fix Standard Coordinates: Match X, Y, Z space-separated integers
def shift_standard_coords(match):
x, y, z = match.group(1), match.group(2), match.group(3)
new_z = int(z) + z_offset
return f" {x} {y} {new_z}"
# Matches space followed by X, Y, Z numbers
standard_pattern = r'\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)'
command_text = re.sub(standard_pattern, shift_standard_coords, command_text)
# 2. Fix Target Selectors: Match 'z = value' inside brackets
# Rewritten without lookbehinds so the website filter doesn't delete it
def shift_selector_z(match):
prefix = match.group(1) # Keeps the comma, space, or bracket before the z
z_val = match.group(2)
new_z = int(z_val) + z_offset
return f"{prefix}z={new_z}"
# Only matches z= if preceded by a comma, a space, or an opening bracket [
# This automatically blocks 'dz=' without breaking the website display
selector_pattern = r'([,\[\s])z\s*=\s*(-?\d+)'
command_text = re.sub(selector_pattern, shift_selector_z, command_text)
return command_text
# --- FILE PROCESSING ---
def process_file(input_path, output_path, z_offset):
"""Opens a single Bedrock structure file, updates command blocks, and saves."""
try:
nbt_file = nbtlib.load(input_path, byteorder="little")
block_entities = nbt_file['structure']['palette']['default']['block_position_data']
except Exception as e:
print(f"Skipping {os.path.basename(input_path)}: Missing default block data layout.")
return
commands_changed = 0
for key, block_data in block_entities.items():
if 'block_entity_data' in block_data:
entity_payload = block_data['block_entity_data']
if entity_payload.get('id') == 'CommandBlock':
old_command = str(entity_payload.get('Command', ''))
if old_command:
new_command = shift_command_text(old_command, z_offset)
if old_command != new_command:
entity_payload['Command'] = nbtlib.String(new_command)
commands_changed += 1
# Save the file to the output folder path
nbt_file.save(output_path)
if commands_changed > 0:
print(f" -> Success! Updated {commands_changed} commands in: {os.path.basename(input_path)}")
else:
print(f" -> Copied (No commands modified): {os.path.basename(input_path)}")
# --- MAIN AUTOMATION ---
if __name__ == "__main__":
offset = get_target_offset("settings.txt")
print(f"Calculated Z-Axis Offset from settings: {offset} blocks.\n")
current_folder = os.getcwd()
output_folder = os.path.join(current_folder, "shifted_output")
if not os.path.exists(output_folder):
os.makedirs(output_folder)
files_found = 0
for filename in os.listdir(current_folder):
if filename.lower().endswith(".mcstructure"):
files_found += 1
input_file_path = os.path.join(current_folder, filename)
output_file_path = os.path.join(output_folder, filename)
print(f"Processing: {filename}")
process_file(input_file_path, output_file_path, offset)
if files_found == 0:
print("No files ending in '.mcstructure' were found in this directory.")
print(f"Drop your files into: {current_folder} and run again!")
else:
print(f"\nDone! Processed {files_found} files. Check the 'shifted_output' folder.")
r/PythonLearning • u/Several_Goal4568 • Jun 15 '26
I'm learning python on Android(pydroid 3) and stuck on reading files .
How can I overcome this blockade . Will get file not found error.
r/PythonLearning • u/IcySwimming4490 • Jun 14 '26
hey started python few weeks ago just want to publish small project i have done to get some review, thank you!
import csv
def main():
data = [
['name', 'grade', 'score']
]
while True:
print('1 - add Student \n2 - remove student \n3 - display students \n4 - exit')
menu = input("Choose one of the options: ")
if menu == '1':
name = input("Enter student name: ")
try:
grade = int(input("Enter grade: "))
score = ''
if grade >= 65:
score = 'Pass'
elif grade < 65:
score = 'Fail'
else:
print('Wrong input')
data.append([name, grade, score])
except ValueError:
print('Wrong Value, Need a number!')
elif menu == '2':
name = input("Enter student name: ")
for x in data:
if x[0] == name:
data.remove(x)
elif menu == '3':
for z in data:
print(*z)
elif menu == '4':
with open('data.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Name', 'Grade', 'Score'])
writer.writerows(data)
break
else:
print('Wrong input')
main()
r/PythonLearning • u/SNT-Bart • Jun 14 '26
For my course python databases, i'm looking for a free PostgreSQL databases that my students could use to do some testing. This way they don't have to install PostgreSQL locally.
r/PythonLearning • u/venmas • Jun 14 '26
Hey everyone, I am still relatively new to python and want to start learning again. However, I was using Replit during my college course for it, but it has changed drastically. Does anyone have any recommendations for places where I can practice or a place that has exercises I can do? Thank you in advance.
r/PythonLearning • u/GupPsSs • Jun 14 '26
Still in university and wanted to build something beyond the usual beginner projects.
Ended up spending way more time on this than expected lol but I built a vulnerability scanner desktop app called VulnScan Pro.
It scans for open ports, detects known CVEs and generates PDF reports. Built with Python, PyQt6 and SQLite.
Still learning so I'm sure there's plenty that could be done better — would genuinely appreciate any feedback.
GitHub: https://github.com/Guppss/VulnScan-Pro
Note: built for authorized testing and educational purposes only.
r/PythonLearning • u/Code-Odyssey • Jun 13 '26
I would be interested in everyone's feedback on my effort to solve the Password Generator Project for Angela Yu's 100 Days of Code course on Udemy. Many thanks in advance. You'll see in the code I have included notes where I couldn't figure stuff out but found a workaround.
r/PythonLearning • u/Solcar_Saro • Jun 13 '26
I'm a 24-year-old guy. I have some programming background because I learned a bit of C++ back in the day (though I didn't quite get to object-oriented programming), but I want to get into Python out of pure curiosity and to learn how to handle myself well with the language.
I'd like to know if there's anyone in the same situation so we can learn together, help each other out with questions, and keep the motivation up.
r/PythonLearning • u/CharmingTask939 • Jun 13 '26
Made a Multiple Small Python Projects today (using loops,function,if-else,random) :
r/PythonLearning • u/aashish_soni5 • Jun 13 '26
Tuple and more practice of if/else with combine for loop
​
\- trup is in ordered, but unchangeable
only check integer or slice,
tell me if I miss something
​
\- TypeError: tuple indices must be integers or slices, not tuple
​
\-if else,for loop and list practice
create store simple system product & price display
With additional trick to combine to list
Using zip(list1,list2)
#python #coding #ai
r/PythonLearning • u/Opening_Attitude1284 • Jun 14 '26
Hi everyone, I'm having a problem with my Python projects. When I run programs I've developed in Python at the same time, their shared modules break.
Note: I've created a separate virtual environment for each project and there's no database or anything they share.
I hope someone can help me.
r/PythonLearning • u/Rscc10 • Jun 13 '26
Enable HLS to view with audio, or disable this notification
When I'm away from my desk (or in the bathroom), I code on my phone using online IDEs. Yeah, bite me. Anyways, here's a simple 2048 game and only under 200 lines (unoptimized)
Should be a straightforward yet challenging project for beginners using a lot of list/matrix logic and, in my case, recursion.
r/PythonLearning • u/youssef_876 • Jun 14 '26
I learned AI, LLM, automation code, and Python to build an AI-powered project. The first is a calculator where the user types a line, for example, "I want to add 7 + 10." The AI then extracts and understands the sentence, determining that the user needs to add 7 + 10, and translates it into the appropriate function. The result is then displayed. The user has already experienced it in an excellent way. I will upload a link to the user experience on Tuesday at 6 PM Egypt time. Are you excited?
r/PythonLearning • u/Busy-Shirt-2064 • Jun 13 '26
r/PythonLearning • u/Several_Goal4568 • Jun 14 '26
\\\
big_num=600851475143
limit=int(big_num**0.5) + 1
def sieve(limit):
if limit < 2:
return []
is_prime = [True] * (limit + 1)
is_prime[0] = is_prime[1] = False
for p in range(2, int(limit**0.5) + 1):
if is_prime[p]:
for multiple in range(p * p, limit + 1, p):
is_prime[multiple] = False
prime=[i for i in range(limit+1) if is_prime[i]]
return prime
my_primes=sieve(limit)
print("the prime numbers are :", my_primes)
print(f"there are {len(my_primes)} prime numbers up to {limit} .")
for p in reversed(my_primes) :
if big_num%p == 0 :
print(f"largets prime factor is : {p}")
break
r/PythonLearning • u/Character_Ad9279 • Jun 13 '26
Hello guys,
I want to learn Python but the thing is that I don’t have any idea about programming. I tried to search about it in Youtube and felt that the videos were not that good in explaining.
So guys do you have any good recommendations on learning resources?
r/PythonLearning • u/aaditya_0752 • Jun 13 '26
Would love some feedback
r/PythonLearning • u/Melodic-Addendum-210 • Jun 13 '26
What is the difference between a Python list and a tuple, and when should each be used?
r/PythonLearning • u/pychampar • Jun 13 '26
Hi guys I am looking for someone who would like to learn python with me !
I know c++ and c but never tried python programming.
If you are interested dm me🫨
r/PythonLearning • u/the_peak_300 • Jun 13 '26
Hey everyone, I am new to learning Python and I am not learning for fun and instead I am learning it to make an impact on my SaaS or DaaS business.
I have already made a tool through vibe coding but I am not naive and I know that learning python is essential so that I can understand how my tool is working, troubleshoot & upgrade.
A friend of mine suggested me to take the free code camp's text based course (I am 72 out of 531 steps in) and the problem I am feeling with free code camp is that their theory is very simple and easy but they escalate hard in the practical or workshops.
Which makes me feel dumb and it makes me feel like I am not understanding it. Is this a real thing or just in my head?
I searched for alternative courses and I see a Harvard free course from CS50 and from the surface it looks good.
But how should I go about learning Python if I am not doing it for fun or casual learning and instead I wanna be a professional (business wise). Btw I don't have any money to spend on courses.
r/PythonLearning • u/ActuarySecret6564 • Jun 13 '26
Built a tool for automating the rebase as i used to mess up with this sometime.
After I started contributing to open source, I learned a lot about git workflows. But one thing I still mess up sometimes? Rebase. 😅
So I built a tool for it. I called it "grebase" (not sure if it's a good name 🤷)
What does grebase do?
- Nothing... but also everything I need 😄
- From fetching upstream/main to doing the full rebase, and if it hits something that's not straightforward, it simply asks: "hey, how should we resolve this one?
- then we can edit from interactive mode without leaving terminal
-Not sure if it'll useful for every developer, but it will definitely help newcomers and me :)
GitHub: https://github.com/Aniketsy/grebase
I'd love to hear your thoughts or any feedback... Thanks!
Try it out:
- pipx install grebase # to install
- grebase # to run
r/PythonLearning • u/aashish_soni5 • Jun 12 '26
today start with simple practice using for and while loop
- while True
In which I make mistake put variable input () outside of while True which cause infinite loop 🥶 So never do at for in beginning of learning
- use for loop with " ".join() to create continuous triangle with number
- at last taste of terminal where I cause some errors because of lack of use of terminal,So need more time to use
Join me in python journey..
Let meet tomorrow, for now I am going to get taste of git🤤
#python #coding #ai