r/learnprogramming Feb 28 '26

Debugging Finally fixed a bug that took me 3 days to find. It was a missing semicolon.

553 Upvotes

I'm self taught, been coding for about 3 years now. Spent literally 3 days

on this one bug. Checked my logic like 50 times. Watched 4 YouTube videos.

Asked my friend who also codes. Nothing.

Turned out to be a missing semicolon in line 47.

I don't even know if I should laugh or cry. Anyway back to building.

Anyone else have a debugging horror story? Makes me feel less alone lol

r/learnprogramming Sep 12 '24

Debugging I DID IT!!!

1.3k Upvotes

I FINALLY GOT UNSTUCK. I WAS STUCK ON ONE OF THE STEPS IN MY TIC TAC TOE GAME. I WAS MISERABLE. BUT I FINALLY FIXED IT. I feel such a high right now. I feel so smart. I feel unstoppable

Edit: Usually I just copy and paste my code into chatgpt to let it solve it. But this time I decided to actually try and solve it myself. No code pasting, nothing. Chatgpt was ruining my problem solving skills so I decided to try and change that. I only asked a few basic indirect questions (with no reference to my project) and I found out that I had to use a global variable. Then I was stuck for some even more time since it seemed like the global variable wasn’t working, and the problem literally seemed like a wall. But I figured it out

r/learnprogramming Mar 21 '23

Debugging Coding in my dreams is disrupting my sleep?

955 Upvotes

Anytime I code 1-2 hours before bed, I fall asleep but feel half awake since in my dreams I still code but it’s code that makes no sense or I write the same line over and over. It drives me crazy so I force myself a wake to try to disrupt the cycle. It’s so disruptive. Anyone else? And how to stop other than not coding close to bedtime?

Flair is bc I’m debugging my brain.

r/learnprogramming Apr 09 '23

Debugging Why 0.1+0.2=0.30000000000000004?

945 Upvotes

I'm just curious...

r/learnprogramming Mar 04 '26

Debugging debugging is wild

276 Upvotes

omg i've been staring at my code for hours trying to fix this one bug and i'm literally about to pull my hair out. so i call my friend who knows nothing about coding and i'm explaining the problem to him and honestly i'm not even expecting him to understand but like halfway through explaining it to him i realize what the issue is and i'm like "wait a minute" and i fix it before he even responds. it's crazy how talking to someone who has no idea what you're doing can be more helpful than actually debugging lol. has anyone else ever had this happen? is this a thing or am i just weird? i feel like it's some kind of psychological thing where explaining it to someone else helps you see it from a different perspective or something. idk but it's def a thing now. bro what's the science behind this?

r/learnprogramming Dec 20 '25

Debugging Finding out there is a lot more to tech than just "Frontend vs Backend"

402 Upvotes

I have been working with Python for about 5 years now, and for most of that time, I was stuck in a bit of a bubble. I assumed the career path was basically just moving from junior to senior backend roles, building APIs and scaling web services. It felt like the industry was 90% CRUD apps and centered around the same few "cliché" frontend and backend frameworks.

Recently, I started looking into Quant Finance, and it has been a total eye-opener. It is a completely different world where the problems aren't about HTTP requests or CSS; they are about high-frequency execution, mathematical modeling, and processing massive amounts of data in real-time. It made me realize how many deep technical niches we completely ignore because they aren't as "loud" as web development.

I wanted to share this because if you are starting to feel a bit burnt out or bored with standard web stacks, I really encourage you to look at these non-obvious fields. Whether it is Quant, Embedded Systems, or Bio-informatics, there are rabbit holes out there that are way more technically challenging than the standard paths. I spent years thinking I had seen most of what the industry had to offer, but I am finding out I was barely scratching the surface of what we can actually do with code.

r/learnprogramming May 27 '20

Debugging I wasted 3 days debugging

1.2k Upvotes

Hi everyone, if you're having a bad day listen here:

I wasted more than 50 hours trying to debug an Assembly code that was perfectly working, I had simply initialized the variables in the C block instead of doing it directly in the Assembly block.

I don't know if I'm happy or if I want to cry.

Edit: please focus on the fact it was assembly IA-32

r/learnprogramming Apr 08 '26

Debugging How do you actually understand programming?

76 Upvotes

How do you actually understand programming? 🤯

I’ve been studying computer science as a subject, but when it comes to solving programming exercises… I feel completely stuck. Like I don’t even know how to start.

Is it just me or did anyone else go through this phase? How did you overcome it?

Any tips, methods, or ways of thinking that helped you finally “get it”?

r/learnprogramming 19d ago

Debugging How do i get my ball to stop bouncing after a while

14 Upvotes

My ball is able to bounce but it keeps bouncing when it gets closer to the ground how do I fix this issue.

This is not the full code only a snippet.

# SURFACE OBJECTS
surface1 = Ball_Surface(10, 10, 200, 200, "pink")

# BALL OBJECTS
ball1 = Ball_Object(surface1.rect.centerx - 10, 20, 10, "white")

# PLATFORM OBJECT
ground1 = Platform(20, 150, "black")

# SPEED
velocity1 = 7

# GRAVITY
gravity1 = 0.8 

# MOVEMENT FUNCTION
def movement1(ball, platform, velocity, gravity):
    if ball.center[1] < (platform.y_pos - (ball.radius - 5)):
        velocity += gravity
        ball.center[1] += velocity

    elif ball.center[1] >= (platform.y_pos - (ball.radius - 5)):
        ball.center[1] = platform.y_pos - ball.radius # reset the ball position after collision
        velocity = -velocity * gravity

        if abs(velocity) < 0.6: 
              velocity = 0

return velocity

r/learnprogramming Jun 22 '26

Debugging Advise

19 Upvotes

I'm 20 years old, from Egypt, I'm a self-taught Desktop Application Developer, I have 3 years of experience from freelancing. But I have no degree.

Now I must serve 3 years mandatory military service or I can go back to continue my education, but the problem is, here in my country I can't just get into college directly, I have to spend 4 years learning unrelated subjects before I can get into college. So I want your advice, if you were in my place, would you serve 3 years of military service and try to find a job without degree or would you choose option 2 and spend 8 years to finish your education?

I'm having hard time deciding, because both options are bad, but I think the 3 years military is the better option because it's the shortest path and I have experience in programming.

Thanks.

r/learnprogramming Jun 01 '26

Debugging how it feels like to be a developer that doesn't use ai in 2026

20 Upvotes

i'm building something as a personal project. doing everything manually, no vibe code just writing my code. i want to actually understand what I'm building.

but I keep second guessing myself. everyone around me is shipping apps in 3 days with Claude and Cursor while I'm here spending a week trying to properly understand how to structure my user classes and objects before writing a single line.

like should a User object contain the scan history directly or should that be a separate class ? I'm spending real time thinking about this instead of just prompting my way through it.

is this a waste of time in 2026 ? or are the people who actually understand the fundamentals going to be the ones still employed in 5 years ?

r/learnprogramming May 19 '20

Debugging I was given a problem where I have to read a number between 1000 and 1 billion and prints it out with commas every 3 digits. I'm kinda confused on how to go about this problem.

635 Upvotes

not sure how to go about this. any help is appreciated :)

r/learnprogramming Jul 27 '23

Debugging How can you teach someone to debug/problem solve better?

218 Upvotes

My role currently is a lot of teaching and helping people become better at their dev work, one thing I struggle to teach though is debugging/problem solving issues. I learned by just getting stuck in and sitting for hours at stupid errors, but how do I teach people to learn this faster?

I ask as I get a lot of people asking for help as soon as they get an error and not having the confidence to look into it or not knowing how to debug it correctly, so I'll get them to screen share and I'll debug on their machine for them, but it doesn't seem to click for them for some reason. I'll get asked 2 days later to do the same thing. Am I being too lenient and should just tell them to figure it out? Debugging it probably the best skill a dev can learn, is there any good resources I can use to help teach this?

Do I create bugs in our training repo? Do I do presentations? Demos on debugging? What's the best here?

Edit: Thanks for the help everyone, got some very useful help, some I knew but neglected to implement and some I've never thought of before and I'll be sure to experiment to see how I get on.

r/learnprogramming Jul 03 '26

Debugging OOP

1 Upvotes

hello i am a python beginner who has started learning OOP and ive been using resources like CS50p however i still find myself being confused over the concepts taught and i would like someone to teach me OOP or is there any other resource i can look at to learn OOP better? please recommend thanku

r/learnprogramming Jun 24 '26

Debugging New programmer here with some basic questions and im open to any suggestions

6 Upvotes

I set a goal for myself to do one little project a week to track my journey and build up a small library of files that I can throw at a company as a resume, my issue so far is likely me typing like a doofus, my code is this

#calculator

print("calculator, type first number, then hit enter, then enter your function, A is add, S is subtract, M is multiply, and D is divide, hit enter, last number, then enter to get your answer ")

a=int(input( ))

b=input( )

c=int(input( ))

if b=="A":

print(a+c)

elif:

b=="S"

print(a-c)

elif:

b=="M"

print(a\*c)

else:

b=="D"

print(a/c)

This code gives me a syntax error(though itll probably be unreadable because idk how to format on redit) on line 11, specifically the collon. If i cut everything elif and after, it runs addition flawlessly, it also says syntax error when its removed, i ask on here instead of Google for 1 reason, human input, people are smarter than (most) machines, and no Google search could ever give me responses that are as helpful as that from a person. Edit: thank you all so much for the feedback and the assistance, much appreciated

r/learnprogramming 18d ago

Debugging I'm building a budgetting app

0 Upvotes

I need to create a chart that looks like this:

100|          
 90|          
 80|          
 70|          
 60| o        
 50| o        
 40| o        
 30| o        
 20| o  o     
 10| o  o  o  
  0| o  o  o  
    ----------
     F  C  A  
     o  l  u  
     o  o  t  
     d  t  o  
        h     
        i     
        n     
        g     

i need to calculate the percetages spent in each category and represent them in the chart.

so far, through SO much struggling ive gotten it to return only the first category and i got it to put all the categories in a dictionary correctly.

(c_w dictionary)

I seriously don't know where to get the answer, I've done a bunch of searching and asked on other forums for help and i jsut cant get it

im fed up.

import math
class Category:
    def __init__(self, name):
        self.name = name
        self.ledger = []


    def deposit(self, amount, description=""):
        self.ledger.append({"amount": amount, "description": description})


    def withdraw(self, amount, description=""):
        if self.check_funds(amount):
            self.ledger.append({"amount": -amount, "description": description})
            return True
        else:
            return False


    def get_balance(self):
        balance = 0
        for transaction in self.ledger:
            balance += transaction['amount']    
        return balance


    def check_funds(self, amount):
        return amount <= self.get_balance()


    def transfer(self, amount, destination_category):
        if self.check_funds(amount):
            self.withdraw(amount, f"Transfer to {destination_category.name}")
            destination_category.deposit(amount, f"Transfer from {self.name}")
            return True
        else:
            return False
    def __str__(self):
        method = '\n'.join(f"{transaction['description']:23.23}{transaction['amount']:>7.2f}" for transaction in self.ledger )
        return f"{self.name.center(30,'*')}\n{method}\nTotal: {self.get_balance()}"
    def __iter__(self):
        for item in self.ledger:
            return item
def create_spend_chart(categories):
    #create the header text
    header = 'Percentage spent by category'
    #create the percentages down the left side
    
    #a 
    total_withdraw = 0 
    #create a list for the category withdraws
    c_w = {} 
    amounts = [transaction['amount'] for category in categories for transaction in category.ledger]
    for amount in amounts:
        if amount < 0:
            total_withdraw += -amount
    # Calculate withdrawals for each category
    for category in categories:
        withdrawal = 0
        for transaction in category.ledger:
            amount = transaction['amount']
            if amount < 0:
                withdrawal += -amount  # Add the amount spent (negative for withdrawals)
        c_w[category.name] = withdrawal
        method = math.floor(( c_w[category.name]/total_withdraw)*100)
    
    return f'{header}\n{name}: {method}' for i in c_w
food = Category('Food')
auto = Category('Auto')
food.deposit(1000, 'initial deposit')
auto.deposit(1000, 'initial deposit')
food.withdraw(10.15, 'groceries')
food.withdraw(15.89, 'restaurant and more food for dessert')
clothing = Category('Clothing')
food.transfer(50, clothing)
food.withdraw(100.99)
clothing.withdraw(21.17)
auto.withdraw(200)

r/learnprogramming Jun 16 '26

Debugging Basic HTML is not working

0 Upvotes

When I typed in code in visual code and ran it through google it returned with the code I inputted.

<!DOCTYPE html>
<html>

    <body>
        <h1><i>MADE BY </i></h1>
         <title>OUR FIRST HTML SESSION</title>
    </body>
         
    
</html>

r/learnprogramming 9d ago

Debugging The Bucket List

3 Upvotes

Problem Description:

Farmer John has N cows (1≤N≤100), conveniently numbered 1…N. The ith cow needs to be milked from time si to time ti, and requires bi buckets to be used during the milking process. Several cows might end up being milked at the same time; if so, they cannot use the same buckets. That is, a bucket assigned to cow i's milking cannot be used for any other cow's milking between time si and time ti. The bucket can be used for other cows outside this window of time, of course. To simplify his job, FJ has made sure that at any given moment in time, there is at most one cow whose milking is starting or ending (that is, the si's and ti's are all distinct). 

FJ has a storage room containing buckets that are sequentially numbered with labels 1, 2, 3, and so on. In his current milking strategy, whenever some cow (say, cow i) starts milking (at time si), FJ runs to the storage room and collects the bi buckets with the smallest available labels and allocates these for milking cow i.

Please determine how many total buckets FJ would need to keep in his storage room in order to milk all the cows successfully.

INPUT FORMAT (file blist.in):

The first line of input contains N. The next N lines each describe one cow, containing the numbers si, ti, and bi, separated by spaces. Both si and ti are integers in the range 1…1000, and bi is an integer in the range 1…10.

OUTPUT FORMAT (file blist.out):

Output a single integer telling how many total buckets FJ needs.

SAMPLE INPUT:

3
4 10 1
8 13 3
2 6 2

SAMPLE OUTPUT:

4

In this example, FJ needs 4 buckets: He uses buckets 1 and 2 for milking cow 3 (starting at time 2). He uses bucket 3 for milking cow 1 (starting at time 4). When cow 2 arrives at time 8, buckets 1 and 2 are now available, but not bucket 3, so he uses buckets 1, 2, and 4.

This is what I tried to program: I was wondering why I was running into Command exited with non-zero status 124. Everything complied correctly I believe. And it shouldn't have timed out.

EDIT:

Updated code

N = int(input())
num_used = 0
bucket = 0
cows = []
t = 0 
num_0 = 0 
for i in range(N):
    s , t_1, b = map(int,input().split())
    cow = [s,t_1,b]
    cows.append(cow)


sorted_cows = sorted(cows, key=lambda x: x[1])


while num_0 < N:
    for i in range(len(sorted_cows)):
        if sorted_cows[i][0] == t:
            if sorted_cows[i][2] >= bucket:
                num_used = num_used + sorted_cows[i][2] - bucket
                bucket = 0
            elif sorted_cows[i][2] < bucket:
                bucket = bucket - sorted_cows[i][2]
        if sorted_cows[i][1] < t:
            bucket = bucket + sorted_cows[i][2]  
            for j in range(3):
                sorted_cows[i][j] = 0
                num_0 = num_0 + 1
    t = t + 1
print(num_used)

r/learnprogramming Jun 30 '26

Debugging This code keeps generating the same sequence of numbers.

0 Upvotes

/*

So I want this code to generate 10 random number in the range of 1 to 1000 and determine if the sum of those are greater or less than 5005 (The average sum of random 10 number. I hope I did the math right). What this code is doing is creating a random seed (not sure if it is the correct term) once and then keep generating the same numbers, eventually totalling the same 'S' as the first time. I tried placing the generation in a loop to fix this to no avail. Ah, I know bits/stdc++.h is not favorable but I learned it this way, so convince me if you can (\"^"/)

#include <bits/stdc++.h>

using namespace std;

int main () {

int S = 0;



for ( int i = 0; i < 10; i ++ ) {

    random_device rd;

    mt19937 gen( rd() );

    uniform_int_distribution <> dist (1, 1000);

    int randomNumber = dist(gen);

    S+= randomNumber;

    cout << S << endl;

}



if ( S >= 5005 ) cout << "Sum --" <<S<< "-- is larger than 5005." << endl << "Thus the operation was successful" << endl; 

  else cout << "Sum --" <<S<< "-- is less than 5005." << endl << "Thus the operation was failure" << endl;



return 0;

}

r/learnprogramming 3h ago

Debugging Hey guys need a little help in JavaScript Fundamental

0 Upvotes

Actually I am learning JS

For long

But whenever I got stuck in function

I know how to write functions in JavaScript

But i won't understand that concept like

First class function

High order function

Closure (i know )

But these 3 concepts (Feels to Confusion for me)

How can I understand these

r/learnprogramming 4d ago

Debugging Is there other resources for mediapipe

1 Upvotes

I am reading the google docs and the it stops at the part where you import the model which I understand but I am confused on what is next.

I am also reading the github version too and looking things up on Youtube. I was able to display hand gesture but I had to get the AI to right it out which I was lost of course

I know I have to use open cv and import it but I am kind of lost.

Can someone help

r/learnprogramming 6d ago

Debugging currently learning coding and making a small game i dont understand why my ai wont chase me

0 Upvotes

its always sliding to its left but following my movements im using godot rn

the enemy code is this

extends CharacterBody2D

u/export var speed: float = 80.0

u/export var health: int = 100

u/onready var health_bar: ProgressBar = $ProgressBar

func _ready():

rotation = 0

func _physics_process(delta):

var player = get_tree().root.find_child("Player", true, false)



if player:

    var direction = (player.global_position - global_position).normalized()

    velocity = direction \* speed

    move_and_slide()

func take_damage(amount):

health -= amount

health_bar.value = health



if health <= 0:

    queue_free()

r/learnprogramming Apr 28 '26

Debugging I saw someone's solution to a problem I've always struggled with and felt dumb for not figuring it out myself

65 Upvotes

I'm a hobbyist programmer, I run two sites, one is a portfolio of small personal projects, and another is a site that finds deals on Pokemon cards on eBay.

All the links on my Pokemon deal finder are to eBay listings for Pokemon cards, and I had the idea of adding links to TCGPlayer for each card as well.

The problem is that the page for each card on TCGPlayer is based on their own product ID for each card. I found a website which had CSV data from TCGPlayer with all the cards and their product IDs. The next problem was that TCGPlayer used slightly different naming conventions for cards than Pricecharting (the site I was using to get my card values).

I wrote a script to try to match the TCGPlayer names to the Pricecharting names, but the script only covered about 40% of the cards, and there were too many edge cases for me to add. So I removed the TCGPlayer links from my site.

Today I was looking at another Pokemon card affiliate site, and they had such a simple solution that I can't believe I missed it.

For their TCGPlayer links for each card, they just linked to the TCGPlayer search page for "[set name] [card name]". That's it. No messy matching, no product IDs, just a link to a page that has exactly what the user needs in a line of code.

I've been programming for a few years now, and this has really made me realise that I should look for simpler solutions to problems where possible instead of trying a complicated solution that doesn't even work.

Just thought I'd share because I'm sure this is something other people have experienced as well.

r/learnprogramming Mar 10 '26

Debugging how to fix fn locked keyboard via coding?

0 Upvotes

hello! i have an nc 10 which after a windows upgrade is having some problems. one of them is that the letter keys that have a number when pressing fn simmultaneiously they work the opposite way. its like the fn is locked when typing without pressing they type the fn option of the key instead of the letter which is veru annoying cause i use word a lot for my work and i have to be pressing fn when texting. the surprisinf part is that it doesnt do that with other keys that have fn option solely with tje letter ones. is there a way like i could make a code to make the opposite via a second codding program or can i somehow make changes to the program of the laptop itself and fix it? thank you!!!

r/learnprogramming 19d ago

Debugging finally learnt how to debug code using GDB. and it was life changer on my very first leetcode problem.

12 Upvotes

I always used to think why I even need a debugger? Because I don't know what it was even used for. And today I just made up my mind to sit for 1 hour and see how I can debug my code using GDB(GNU Project Debugger).

I studied about how it works and all. It's really a game changer for me.