Programming Horror

222 readers
2 users here now

Share strange or straight-up awful code.

founded 2 years ago
MODERATORS
1
9
submitted 4 months ago* (last edited 4 months ago) by moosetwin@lemmy.dbzer0.com to c/programminghorror@lemmy.world
 
 

"maybe I shouldn't have learned programming from youtube tutorials..."

it's supposed to turn a list (e.g. [1, 2, 3, 4, 1, 0] ) into [1, 2, 3, 4, 10]

it actually works (for my use-case, anyways) but is completely ridiculous and I'm about to remove it in favor of bypassing this problem entirely

text code if you want:

newplant = [1, 2, 3, 4, 1, 0] # can be a list of any positive int with a 0 before another number
for number in newplant:
            if number == 0:
                newplant[(newplant.index(0) - 1):(newplant.index(0) + 1)] = [int(''.join(str(v) for v in [newplant[(newplant.index(0) - 1)], 0]))]
2
3
 
 

No dig to Jr Devs. I just want to program all day and talk to nobody. :)

4
 
 
5
1
submitted 2 years ago* (last edited 2 years ago) by CombatWombatEsq@lemmy.world to c/programminghorror@lemmy.world
 
 

Full stack trace? Server id??? pid?????

6
 
 

cross-posted from: https://lemmy.world/post/701900

Me: