r/programminghorror • u/ferro31_ • 25d ago
Python Rate my python "Hello, World!" implementation
# Write a function `greet` that returns "hello world!"
import os
def check_if_contains(l1, l2):
contains_all = True
for ind in range(len(l2)):
if l1[ind] != l2[ind]:
contains_all = False
return contains_all
def get_length(l, substract):
i = 0
for _ in range(len(l)):
i += 1
if substract:
return i - 1
if not substract:
return i
def append_item(l, c):
l.append(None)
length = get_length(l, True)
l[length] = c
def build_string(l):
string_builder = ""
for ind in range(len(l)):
string_builder += l[ind]
return string_builder
def greet():
with open(os.getcwd() + "/solution.py", "r", encoding="UTF-8") as f:
lines = f.readlines()
req = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!']
temp = []
for line in lines:
for char in line:
append_item(temp, char)
if check_if_contains(req, temp):
if get_length(req, False) == get_length(temp, False):
return build_string(temp)
else:
temp = []
43
Upvotes
46
25
u/letmehaveanameyoudum 23d ago
typa shit you gotta do to impress the vibe coding manager and get a raise
4
2
2
u/spshkyros 22d ago
... you have so many errors in it that I think are NOT part of your joke o.O or maybe they all are and you went all in on the horror o.O
1
1
2
u/mankeyless 23d ago
Impressive, what model did you use?