r/pythonhelp • • Apr 09 '25

Is there really a downside to learning Python 2 instead of 3??

1 Upvotes

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 • • Oct 14 '25

I'M AN IT FIRST YEAR COLLEGE I STUDY PYTHON AND I SUDDENLY LOST, I'M LOST NOW AND I WANT TO CREATE A PROJECT CALLED STUDY TRACKER THAT HAVE GRAPHS AND POMODORO TIMER

0 Upvotes

So at first I was in programming python I'm really exited to learn because I slowly understand or rather progression of learning but then as time progress it's getting harder to me to understand topics that started when i learn modules and defining because there is so many modules like how do you find what needed to your program to work I'm very lost right now I don't even know I can handle programming i really want to learn it i really need tips and what to learn, learning the basics is very easy like loops or logical operators but this time is different I hope someone can help me.


r/pythonhelp • • Jul 28 '26

Что делать если не устанавливается python

0 Upvotes

Я пишу в командной строке пайтон инсталл и начинаю писать команду но у меня вылезает ошибка то что пип не установлен но установить не могу


r/pythonhelp • • May 31 '23

What is pygame?

1 Upvotes

Hi guys i started to learn python but didnt know if i should use it because i dont know what it does so can u guys explain in a simple way?


r/pythonhelp • • Dec 08 '21

PYTHON ASSIGNMENT PLS SOMEONE LOL

1 Upvotes

Read in the included data file and write it to a file named sorted_data.txt with the same data, but order the columns in ascending alphabetical order.

https://www.dropbox.com/s/snhowdtcne6zuuf/MOCK_DATA-3.txt?dl=0

That is the link to the data file that is supposed to be initially read in.


r/pythonhelp • • Jun 28 '21

Command for checking what you’ve typed

Thumbnail
gallery
1 Upvotes

r/pythonhelp • • May 03 '20

What is happening

Post image
1 Upvotes

r/pythonhelp • • Oct 24 '19

Python Questions

0 Upvotes

I need help with this 3 python questions.

please I just need the answers no explanation please here they are:

  1. A file named data1.txt contains an unknown number of lines, each consisting of a single integer. Write some code that creates a file named data2.txt and copies all the lines of data1.txt to data2.txt.

  2. A file named numbers.txt contains an unknown number of lines, each consisting of a single positive integer. Write some code that reads through the file, ignoring those value that are not bigger than the maximum value read up to that point. The numbers that are NOT ignored are added, and their sum stored in a variable called runsum.

For example, if the sequence of integers in the file were "9 7 5 18 13 2 22 16" the code would ignore: 7, 5, 13, 2 and 16; it would add 9, 18, and 22, storing their sum, 49, into runsum.

3. Two files named numbers1.txt and numbers2.txt both have an unknown number of lines, each line consisting of a single positive integer. Write some code that reads a line from one file and then a line from the other file. The two integers are multiplied together and their product is added to a variable called scalar_product which should be initialized to zero.

Your code should stop when it detects end of file in either file that it is reading.

For example, if the sequence of integers in one file was "9 7 5 18 13 2 22 16" and "4 7 8 2" in the other file, your code would compute:

49 + 77 + 85 + 218

and thus store 161 into scalar_product.


r/pythonhelp • • Feb 07 '20

Help needed asap i have no idea what i’m doing and it’s due in a few hours

Post image
0 Upvotes

r/pythonhelp • • Jul 29 '26

Reddit Post Template Title: I built an automated Python "Infinity Engine" with timed 7s loops, rarity tiers, dynamic storylines, and a cyberpunk terminal UI (500-Unit max run + 5-min idle shutdown)

0 Upvotes

Hey everyone! I’ve been experimenting with background threading, automated compilation cycles, and procedural narrative generation in Python.

I put together a script I call the Infinity Engine. It runs autonomously every 7 seconds, rolls for loot rarity tiers based on telemetry, shifts through dynamic storylines, accumulates resources (stardust/resonance), includes an unstick safety protocol, and features an idle shutdown variant if left untouched for 5 minutes. It scales up to 500 units with a custom cyberpunk terminal UI layout.

Here is the full runnable source code:

import time

import json

import threading

import random

# ==========================================

# Rarity Tier Matrix

# ==========================================

class RarityTier:

STANDARD = 0

PRIME = 1

CELESTIAL = 2

BRINK_PRISM = 3

# ==========================================

# Level Loot System

# ==========================================

class LevelLootSystem:

def roll_level_loot(self, telemetry: dict, current_app_level: int):

result = type('LootResult', (), {})()

fortune_score = telemetry.get("fortune_level", 0.0)

fusions = telemetry.get("fusions_count", 1)

composite_score = (fortune_score * 0.5) + (fusions * 10.0) + (current_app_level * 25.0)

if composite_score > 300.0:

result.tier = RarityTier.BRINK_PRISM

result.bonus_multiplier = 3.5

result.drop_title = "Brink-Prism Anomaly Drop"

result.guaranteed_stat_bonus = {"stardust_rate": 50.0, "void_resonance": 0.95}

elif composite_score > 180.0:

result.tier = RarityTier.CELESTIAL

result.bonus_multiplier = 2.2

result.drop_title = "Celestial Core Relic"

result.guaranteed_stat_bonus = {"stardust_rate": 25.0, "lawful_affinity": 0.80}

elif composite_score > 80.0:

result.tier = RarityTier.PRIME

result.bonus_multiplier = 1.5

result.drop_title = "Prime Barometer Blueprint"

result.guaranteed_stat_bonus = {"stardust_rate": 12.0, "lawful_affinity": 0.50}

else:

result.tier = RarityTier.STANDARD

result.bonus_multiplier = 1.0

result.drop_title = "Standard Atmospheric Drift"

result.guaranteed_stat_bonus = {"stardust_rate": 5.0, "lawful_affinity": 0.25}

return result

# ==========================================

# Story Mediator & Storylines

# ==========================================

class StoryMediator:

def __init__(self):

self.storylines = [

"The Prism Meridian: Convergence",

"The Barometer's Awakening",

"Sub-Zero Protocols",

"Atmospheric Drift",

"Chronos Rift Divergence",

"Stellar Horizon Protocol"

]

self.current_storyline_index = 0

def get_current_storyline(self) -> str:

return self.storylines[self.current_storyline_index]

def shift_storyline(self, new_index: int = None):

if new_index is not None:

self.current_storyline_index = new_index % len(self.storylines)

else:

self.current_storyline_index = (self.current_storyline_index + 1) % len(self.storylines)

return self.get_current_storyline()

def mediate_narrative_threads(self, current_loot_tier: int):

chapter = type('Chapter', (), {})()

title = self.get_current_storyline()

chapter.chapter_title = title

if current_loot_tier == RarityTier.BRINK_PRISM:

chapter.synthesized_lore = f"Active storyline '{title}' converges into a unified cosmic history under high void pressure."

chapter.thematic_resonance = 1.0

elif current_loot_tier == RarityTier.CELESTIAL:

chapter.synthesized_lore = f"Active storyline '{title}' transforms climate anomalies into a permanent archive of fate."

chapter.thematic_resonance = 0.8

elif current_loot_tier == RarityTier.PRIME:

chapter.synthesized_lore = f"Active storyline '{title}' stabilizes baseline matrix vectors under heavy pressure."

chapter.thematic_resonance = 0.5

else:

chapter.synthesized_lore = f"Active storyline '{title}' settles initial weather anomalies into a steady rhythmic drift."

chapter.thematic_resonance = 0.2

return chapter

# ==========================================

# Consistency Engine & Resource Accumulation

# ==========================================

class ConsistencyEngine:

def __init__(self):

self.progression_checkpoint = 0

self.unstick_tokens = 500

self.accumulated_resources = {

"stardust_collected": 0.0,

"resonance_ledger": []

}

def accumulate(self, stat_bonus: dict, resonance: float):

self.accumulated_resources["stardust_collected"] += stat_bonus.get("stardust_rate", 0.0)

self.accumulated_resources["resonance_ledger"].append(resonance)

def trigger_unstick_protocol(self):

if self.unstick_tokens > 0:

self.unstick_tokens -= 1

self.progression_checkpoint += 1

return {"status": "SUCCESS", "remaining_tokens": self.unstick_tokens, "stage": self.progression_checkpoint}

return {"status": "DEPLETED", "remaining_tokens": 0, "stage": self.progression_checkpoint}

# ==========================================

# Narrative Story Generator (~400 Chars)

# ==========================================

class NarrativeStoryGenerator:

def __init__(self):

self.unique_signatures = ["ALPHA-PRISM-9", "OMEGA-VOID-X", "HELIOS-GENESIS-0", "NEXUS-VECTOR-7"]

self.narrative_templates = [

"Deep within the shifting sectors of Unit {app_level}, active telemetry reports severe weather fluctuations linked directly to storyline [{chapter_title}]. Signature [{signature}] detected. {lore} Operatives on the fringe report unexpected data feedback, rallying structural outcomes to balance popular configuration metrics with a thematic resonance of {resonance:.2f}. The grid adapts instantly.",

"As the clock ticks into Unit {app_level}, core systems register a sudden spike under storyline [{chapter_title}]. Unique matrix identifier [{signature}] engaged. {lore} Field units work frantically to calibrate the atmospheric pressure valves, rallying outcomes to balance popular configuration parameters while maintaining a steady thematic resonance of {resonance:.2f}. Network stability holds firm.",

"Tracing the anomalies of Unit {app_level} under signature [{signature}], project administrators encounter the legacy of storyline [{chapter_title}]. {lore} Environmental matrices fracture and reassemble, successfully rallying outcomes to balance popular configuration thresholds at a thematic resonance of {resonance:.2f}. The digital horizon expands outward."

]

def generate_balanced_story(self, app_level: int, chapter_title: str, lore: str, resonance: float) -> str:

template = random.choice(self.narrative_templates)

signature = random.choice(self.unique_signatures) + "-" + str(random.randint(1000, 9999))

raw_text = template.format(

app_level=app_level,

chapter_title=chapter_title,

signature=signature,

lore=lore,

resonance=resonance

)

if len(raw_text) < 400:

padding_phrases = [

" Synchronizing unique regional sub-networks securely. ",

" Calibrating distinct quantum feedback loops for optimal throughput. ",

" Securing high-uniqueness parameter boundaries against drift. "

]

while len(raw_text) < 400:

raw_text += random.choice(padding_phrases)

return raw_text[:400]

# ==========================================

# Timed Infinity Engine Host (500 Units + Idle Timeout)

# ==========================================

class TimedInfinityEngineHost:

def __init__(self):

self.loot_system = LevelLootSystem()

self.story_mediator = StoryMediator()

self.consistency_engine = ConsistencyEngine()

self.story_generator = NarrativeStoryGenerator()

self.app_level = 1

self.active_constructs = []

self._is_running = False

self._timer_thread = None

self.last_activity_time = time.time()

self.idle_timeout_seconds = 300

def change_storyline(self, new_index: int = None):

shifted = self.story_mediator.shift_storyline(new_index)

print(f"\n[STORYLINE SHIFT] Active storyline manually changed to: '{shifted}'\n")

return shifted

def execute_compilation_cycle(self, telemetry: dict):

self.last_activity_time = time.time()

loot_drop = self.loot_system.roll_level_loot(telemetry, self.app_level)

mediated_chapter = self.story_mediator.mediate_narrative_threads(loot_drop.tier)

self.consistency_engine.accumulate(loot_drop.guaranteed_stat_bonus, mediated_chapter.thematic_resonance)

story_block = self.story_generator.generate_balanced_story(

self.app_level,

mediated_chapter.chapter_title,

mediated_chapter.synthesized_lore,

mediated_chapter.thematic_resonance

)

construct = {

"app_title": f"Infinity: {mediated_chapter.chapter_title}",

"tier": loot_drop.tier,

"drop": loot_drop.drop_title,

"resonance": mediated_chapter.thematic_resonance,

"level": self.app_level,

"story_content": story_block,

"story_length": len(story_block),

"accumulated_stardust": self.consistency_engine.accumulated_resources["stardust_collected"]

}

self.active_constructs.append(construct)

print("╔" + "═" * 78 + "╗")

print(f"║ ⚡ CYBER-NET TERMINAL v4.09 // UNIT [{self.app_level:03d}/500] ⚡" + " " * 31 + "║")

print("╠" + "═" * 78 + "╣")

print(f"║ TITLE : {construct['app_title']:<63} ║")

print(f"║ DROP TYPE : {construct['drop']} (Tier {construct['tier']})" + " " * (47 - len(f"{construct['drop']} (Tier {construct['tier']})")) + "║")

print(f"║ RESONANCE : {construct['resonance']:.2f} | STARDUST ACCUMULATED: {construct['accumulated_stardust']:.1f}" + " " * (19 - len(f"{construct['accumulated_stardust']:.1f}")) + "║")

print("╟" + "─" * 78 + "╢")

print(f"║ STORY OUTPUT ({construct['story_length']} chars):" + " " * 56 + "║")

words = construct['story_content'].split()

line = " "

for word in words:

if len(line) + len(word) + 1 < 77:

line += " " + word

else:

print(f"║{line:<78}║")

line = " " + word

if line.strip():

print(f"║{line:<78}║")

continue_res = self.consistency_engine.trigger_unstick_protocol()

print("╟" + "─" * 78 + "╢")

print(f"║ 🔒 PROTOCOL STATUS: Tokens Left [{continue_res['remaining_tokens']}] | Stage [{continue_res['stage']}]" + " " * (20 - len(str(continue_res['stage']))) + "║")

print("╚" + "═" * 78 + "╝\n")

self.app_level += 1

return construct

def _loop_worker(self, telemetry: dict, max_units: int):

cycles = 0

while self._is_running and cycles < max_units:

if time.time() - self.last_activity_time > self.idle_timeout_seconds:

print("\n[IDLE SHUTDOWN VARIANT] Engine inactive for 5 minutes. Initiating automatic safe shutdown.")

break

if cycles > 0 and cycles % 100 == 0:

self.change_storyline()

self.execute_compilation_cycle(telemetry)

cycles += 1

if cycles >= max_units:

print(f"\n=== [SYSTEM ALERT] Reached target limit of {max_units} units. Settlement final. ===")

print(f"=== Total Accumulated Stardust: {self.consistency_engine.accumulated_resources['stardust_collected']:.1f} ===")

break

time.sleep(7.0)

self._is_running = False

print("=== Timed Looping Engine Cycle Terminated Safely ===")

def start_timed_loop(self, telemetry: dict, max_units: int = 500):

if self._is_running:

return

self._is_running = True

self.last_activity_time = time.time()

print(f"=== Initializing Cybernetic Loop (Target: {max_units} Units | Idle Timeout: 5m) ===")

self._timer_thread = threading.Thread(target=self._loop_worker, args=(telemetry, max_units))

self._timer_thread.start()

def stop_timed_loop(self):

self._is_running = False

if self._timer_thread:

self._timer_thread.join()

if __name__ == "__main__":

host = TimedInfinityEngineHost()

sample_telemetry = {"fortune_level": 95.0, "fusions_count": 6}

host.start_timed_loop(sample_telemetry, max_units=500)

while host._is_running:

time.sleep(1.0)


r/pythonhelp • • Dec 09 '25

Я хочу написать самую сложный вывод "Привет мир!"

0 Upvotes

Здаравствуйте, мой преподаватель в универсисете во время практики поставил последнее задание:
'Напишите программу, которая выводит на экран "Привет, мир!".'

Я хочу ответить на прикол приколом и ищу сложный способ вывода "Привет мир!".
Чесно говоря ничего интересного в голову не приходит какие у вас могут быть мысли на счет этого? Простите если не правильно выбрал сообщество, первый раз на реддит.


r/pythonhelp • • Apr 15 '26

Who Should Learn APIs?

11 Upvotes

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 • • Sep 19 '26

Using AI (ChatGPT/Claude) to learn Python — is this fine or am I sabotaging myself?

0 Upvotes

Been learning Python for a bit now (working through CS50P) and I've started leaning on AI tools a lot when I get stuck — debugging, explaining errors, even generating chunks of code when I'm short on time.

It's helping me move faster for sure, but I've got this nagging feeling I might be skipping the "struggle" part that actually makes concepts stick. So a few questions for people who've been through this:

  1. Is using AI while learning actually fine, or does it hurt long-term retention/problem-solving skills?

  2. If I should cut back, how much? Like — full cold turkey, or just use it for specific things (explaining errors vs. writing code for me)?

  3. If I do cut down, how do I actually get better at writing code on my own? Any habits, resources, or exercises that helped you build real problem-solving muscle instead of just pattern-matching to AI suggestions?

Would really appreciate advice from people who've either made this mistake or found a good balance. Trying to actually become a solid programmer, not just someone who can prompt their way to working code.


r/pythonhelp • • Mar 08 '26

Can somebody tell me whats wrong with my code

2 Upvotes

# V1

#INPUT PART

chess_coords = input("Enter a chess cordintes: ")

#length check

while not len(chess_coords) == 2:

print("Invalid!!!")

chess_coords = input("Try something like e4, e5 or E6: ")

#chcking order

colu=set("ABCDEFGH")

rw=set(123456789)

while not chess_coords[0].upper() in colu :

print("Invali order")

chess_coords = input("Try something like e4, e5 or E6: ")

while ch:

#logic

col = int(ord(chess_coords[0]))

row = int(chess_coords[1])

data = (row+col)%2

#output

if data == 0:

print(f"your {chess_coords} is black colour")

else:

print(f"your {chess_coords} is white colour")

# v2

ro = set("12345678")

co = set("ABCDEFGH")

square = input("Enter the chess square: ")

col = square[0].upper()

row = square[1]

while len(square) != 2:

print("Invalid length")

square = input("Try something like e4, e5 or E6: ")

while col not in co:

print("Invalid coloum ")

square = input("Try something like e4, e5 or E6: ")

while row not in ro:

print("Invalid row")

square = input("Try something like e4, e5 or E6: ")

int(ord(col))

print(col)

int(row)

data = int((col + row))%2

if data == 0:

print(f"your {chess_coords} is black colour")

else:

print(f"your {chess_coords} is white colour")

===> This code uses the concept if the sum of coloum and row is even its black else its white

for E.g: A1 here ord(A)+1 is even so its black


r/pythonhelp • • Feb 21 '26

Problem with final app size

2 Upvotes

Finally i got an exe file for my first python app and it works well but...folder size is 1.7 GB.. is there any way to get it a little lighter?i compiled it with pyinstaller


r/pythonhelp • • Apr 23 '26

Need Assistance With A Problem

2 Upvotes

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

  1. Each row has to have an equal number of 1s and 2s and no 0s

  2. 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 • • Nov 30 '25

Why does Python reverse a list with [::-1]? Can someone explain this slicing logic?

8 Upvotes

Hi everyone!
I’m learning Python and came across the slicing syntax [::-1].

I know it reverses a list, but I don’t fully understand how the negative step works internally.

nums = [1, 2, 3, 4]

print(nums[::-1])

Can someone explain what start:stop:step means in this context and why -1 reverses the order?

Not homework — just trying to understand slicing better.
Thanks!


r/pythonhelp • • May 20 '25

TIPS How do i make this code run?

0 Upvotes

Its supposed to reproduce random music sounds

here is the code:

import time

import playsound as ps

import random

import ("sonidos")

def main():

# Approximate time to work

long_gap_mins = 1

pm_secs = 15

# Time to rest between each sound

short_gap_secs = random_integer = random.randint(1, 10)

# Hours to work

work_hrs = 5

# Source Code

work_secs = work_hrs * 60 * 60

min_secs = 60 * long_gap_mins - pm_secs

max_secs = 60 * long_gap_mins + pm_secs

start_time = time.time()

while(time.time() - start_time < work_secs):

rand_long_gap_secs = random.randint(min_secs, max_secs)

time.sleep(rand_long_gap_secs)

ps.playsound('1')

ps.playsound('2')

ps.playsound('3')

ps.playsound('5')

ps.playsound('7')

ps.playsound('8')

ps.playsound('10')

ps.playsound('16')

ps.playsound('19')

ps.playsound('20')

ps.playsound('21')

ps.playsound('23')

ps.playsound('24')

ps.playsound('27')

ps.playsound('28')

ps.playsound('35')

ps.playsound('36')

ps.playsound('37')

ps.playsound('38')

ps.playsound('42')

ps.playsound('43')

ps.playsound('45')

ps.playsound('47')

ps.playsound('52')

ps.playsound('54')

ps.playsound('55')

ps.playsound('57')

ps.playsound('59')

ps.playsound('61')

ps.playsound('62')

ps.playsound('63')

ps.playsound('66')

ps.playsound('70')

ps.playsound('71')

ps.playsound('73')

ps.playsound('74')

ps.playsound('78')

ps.playsound('79')

ps.playsound('81')

ps.playsound('82')

ps.playsound('84')

ps.playsound('88')

ps.playsound('90')

ps.playsound('91')

ps.playsound('92')

ps.playsound('93')

ps.playsound('94')

ps.playsound('95')

ps.playsound('96')

ps.playsound('97')

ps.playsound('99')

ps.playsound('102')

ps.playsound('103')

ps.playsound('104')

ps.playsound('105')

ps.playsound('109')

ps.playsound('110')

ps.playsound('112')

ps.playsound('114')

ps.playsound('115')

ps.playsound('117')

ps.playsound('119')

ps.playsound('120')

ps.playsound('122')

ps.playsound('123')

ps.playsound('127')

ps.playsound('133')

ps.playsound('136')

ps.playsound('138')

ps.playsound('139')

ps.playsound('140')

ps.playsound('141')

ps.playsound('145')

ps.playsound('154')

ps.playsound('156')

ps.playsound('157')

ps.playsound('162')

ps.playsound('165')

ps.playsound('167')

ps.playsound('170')

ps.playsound('172')

ps.playsound('174')

ps.playsound('177')

ps.playsound('179')

ps.playsound('180')

ps.playsound('181')

ps.playsound('183')

ps.playsound('185')

ps.playsound('187')

ps.playsound('188')

ps.playsound('189')

ps.playsound('190')

ps.playsound('193')

time.sleep(short_gap_secs)

ps.playsound('ShortChurchBells.mp3')

main()

don't ask for the filenames pls


r/pythonhelp • • Mar 05 '25

Any way to make this happen?

0 Upvotes

I have kind of a riddle to solve, any way to fix it? b%3=0 b>a For i in range(a,b,3) What formula can I use to always find how long it will run?


r/pythonhelp • • Oct 11 '25

Where do i go next?

0 Upvotes

I started recently learning python and got fast to Codédex. But now i have finished the free version, where can and should i go next so that my progress doesn’t suffer from it?


r/pythonhelp • • Jun 20 '25

Future: Replace Python with Go?

Thumbnail reddit.com
0 Upvotes

Hey


r/pythonhelp • • Jun 10 '26

Problème Python 2

Thumbnail reddit.com
0 Upvotes

r/pythonhelp • • Apr 29 '26

.pipe() no pandas mudou como escrevo pipelines de dados

Thumbnail reddit.com
0 Upvotes

r/pythonhelp • • Jun 02 '26

Coding for dummies

Thumbnail reddit.com
0 Upvotes

Of late I have been thinking to learn how to code. .the old adage says you cannot an old horse new tricks but I would.like to change that..I have access to the internet( not quite fast unless it's midnight) and a laptop( an old dell core i5)..

I would really want to learn it since our world is leaning in that direction and earn a couple of bucks along the way.so where do I start? ideally I would want something that novices can master amd progress over time.

I'm open to suggestions