/r/learnprogramming

Photograph via snooOG

A subreddit for all questions related to programming in any language.

Welcome to LearnProgramming!


New? READ ME FIRST!

Posting guidelines

Frequently asked questions

Subreddit rules

Message the moderators


Asking debugging questions

If you need help debugging, you must include:

  1. A concise but descriptive title.
  2. A good description of the problem.
  3. A minimal, easily runnable, and well-formatted program that illustrates your problem.
  4. The output you expected, and what you got instead. If you got an error, include the full error message.

See debugging question guidelines for more info.

Asking conceptual questions

Many conceptual questions have already been asked and answered. Read our FAQ and search old posts before asking your question. If your question is similar to one in the FAQ, explain how it's different.

See conceptual questions guidelines for more info.

Other guidelines and links

  1. Frequently asked questions
  2. Asking homework questions
  3. Asking for code review
  4. Answering questions
  5. Learning resources
  6. Other communities

Subreddit rules

1. No unprofessional/derogatory speech

  • Follow reddiquette: behave professionally and civilly at all times. Communicate to others the same way you would at your workplace. Disagreement and technical critiques are ok, but personal attacks are not.

Abusive, racist, or derogatory comments are absolutely not tolerated.

See our policies on acceptable speech and conduct for more details.

2. No spam or tasteless self-promotion

In short, your posting history should not be predominantly self-promotional and your resource should be high-quality and complete. Your post should not "feel spammy".

Distinguishing between tasteless and tasteful self-promotion is inherently subjective. When in doubt, message the mods and ask them to review your post.

Self promotion from first time posters without prior participation in the subreddit is explicitly forbidden.

3. No off-topic posts

  • Do not post questions that are completely unrelated to programming, software engineering, and related fields. Tech support and hardware recommendation questions count as "completely unrelated".

Questions that straddle the line between learning programming and learning other tech topics are ok: we don't expect beginners to know how exactly to categorize their question.

See our policies on allowed topics for more details.

4. Do not ask exact duplicates of FAQ questions

  • Do not post questions that are an exact duplicate of something already answered in the FAQ.

If your question is similar to an existing FAQ question, you MUST cite which part of the FAQ you looked at and what exactly you want clarification on.

5. Do not delete posts

  • Do not delete your post! Your problem may be solved, but others who have similar problems in the future could benefit from the solution/discussion in the thread.

Use the "solved" flair instead.

6. No app/website review requests or showcases

  • Do not request reviews for, promote, or showcase some app or website you've written. This is a subreddit for learning programming, not a "critique my project" or "advertise my project" subreddit.

Asking for code reviews is ok as long as you follow the relevant policies. In short, link to only your code and be specific about what you want feedback on. Do not include a link to a final product or to a demo in your post.

7. No rewards

  • You may not ask for or offer payment of any kind (monetary or otherwise) when giving or receiving help.

In particular, it is not appropriate to offer a reward, bounty, or bribe to try and expedite answers to your question, nor is it appropriate to offer to pay somebody to do your work or homework for you.

8. No indirect links

  • All links must link directly to the destination page. Do not use URL shorteners, referral links or click-trackers. Do not link to some intermediary page that contains mostly only a link to the actual page and no additional value.

For example, linking to some tweet or some half-hearted blog post which links to the page is not ok; but linking to a tweet with interesting replies or to a blog post that does some extra analysis is.

Udemy coupon links are ok: the discount adds "additional value".

9. Do not promote illegal or unethical practices

  • Do not ask for help doing anything illegal or unethical. Do not suggest or help somebody do something illegal or unethical.

This includes piracy: asking for or posting links to pirated material is strictly forbidden and can result in an instant and permanent ban.

Trying to circumvent the terms of services of a website also counts as unethical behavior.

10. No complete solutions

  • Do not ask for or post a complete solution to a problem.

When working on a problem, try solving it on your own first and ask for help on specific parts you're stuck with.

If you're helping someone, focus on helping OP make forward progress: link to docs, unblock misconceptions, give examples, teach general techniques, ask leading questions, give hints, but no direct solutions.

See our guidelines on offering help for more details.

11. Don't ask to ask.

  • Ask your questions right here in the open subreddit. Show what you have tried and tell us exactly where you got stuck.

We want to keep all discussion inside the open subreddit so that more people can chime in and help as well as benefit from the help given.

We also do not encourage help via DM for the same reasons - that more people can benefit

12. Low Effort Questions

  • Do not ask easily googleable questions or questions that are covered in the documentation.

This subreddit is not a proxy for documentation or google.

We do require effort and demonstration of effort.

This includes "how do I?" questions

13. No AI (chatGPT etc.) generated messages/comments. No questions about chatGPT/AI generated code.

  • Such posts/comments will be removed without warning and the poster of ai generated content will be instantly banned.

/r/learnprogramming

4,084,844 Subscribers

1

Self-taught communities

Hello, guys, are there any communities/groups for people who are still learning? (preferably WebDev)

I think would be great to meet online friends who also learn how to code/ build small projects. I’m in the UK btw.

P.S if anybody is interested u can send me a DM.

1 Comment
2024/04/22
17:52 UTC

1

Confused about node.js syntax. "<%%> and >%%<

<% if (jsonData) { %>
<script id="jsonData">var jsonData=<%- JSON.stringify(jsonData) %>;</script>
<% } %>

so in this example, why does it do <% and then {%>? Shouldnt it be like this---> <% {} %>? Why do you cut off the first bracket with a closing tag "%>"?

1 Comment
2024/04/22
17:49 UTC

1

Best Path Forward for Learning Rusty Stacks Creating a Mobile App with Admin Panel

Ps: I don't want to use ChatGPT to do the work for me..

I could use some advice on the best approach for a new project I'm working on. A year ago, I completed a full-stack coding bootcamp, where I learned html,css,js along React and Node.js. However, since joining my current job, I've mainly been working with Python and FastAPI as a backend dev, so I haven't had much experience with JavaScript, React Native, or Firebase since almost 10 months ago.

I'm now tasked with creating a simple mobile app with an admin panel, and I'm excited to dive into these technologies again. However, I'm a bit rusty and not sure about the best way to approach this. The app is expected to have around 6 screens, while the admin panel will have about 5 screens (taking out transition and modals)

I was thinking maybe do a quick project before starting, but then the project is already relatively simple. Thought about doing some JS exercises. watching youtube tutorials?

Do you have any suggestions on the best path forward? Should I go through a comprehensive tutorial or focus on specific areas? Any recommendations on resources or advice on how to tackle this project would be greatly appreciated.

Thank you!

0 Comments
2024/04/22
17:15 UTC

1

How does web programming work under the hood?

I'm finishing up my "systems year" at my university, where we went through our notoriously difficult classes: computer architecture and operating systems.

I enjoyed learning in these classes (not floating point) because it revealed why and what exactly is happening when a computer is executing code. I felt as if everything I wrote beforehand was abstracted nonsense and I definitely became a better programmer/coder/whatever because of it,.

My question is where exactly does this tie in with web programming? My OS professor did mention that compiling and executing a file wasn't the only way to run code, there are also things like the Python interpreter that is running on your system that interprets .py files and executes it through an intermediary. Is this what happens on the web? Is javascript analogous to python, and the browser analogous to the interpreter? Then is the browser executing code..? Obviously JS can't be executing "native" code, but from what I see, it seems like a java situation.. java (aafik) has a compile step, and then an interpreter step (JVM runs the code).

I think I learn the best when I learn from the foundation up. For example, our electrical/computer engineering degree has our students learning about circuits/transistors/the physics behind them first, then goes on to higher and higher levels of abstraction later in the degree. For us CS students, it's the opposite where we learn the high level languages first and then learn the low level languages and how they work later. I guess i'm having trouble piecing together the pieces of the puzzle to get from low level machine code to high level...whatever kind of javascript code executes.

6 Comments
2024/04/22
17:18 UTC

1

Functional Programming Tutors?

Hey all, I’m learning functional programming and its not really clicking with me. I am learning SML/Standard ML and given its an older and not as popular language how do I go about finding people who know it well? Not sure if this is the place to ask but is anyone here proficient in it?

5 Comments
2024/04/22
17:10 UTC

1

What should I learn next in Spring Framework? Is Open Source good for learning?

I am a final year student and I have a basic grasp of Spring (including dependency injection, annotations, and basic CRUD operations) and have implemented these in projects, I'm looking to expand my knowledge further. What should I learn next in Spring?

I'm also interested in exploring open-source projects to deepen my understanding of Spring, is this a good way to understand how spring is used. Could you please suggest any good open-source projects where I can delve into various applications of Spring beyond just backend web development? Any recommendations would be greatly appreciated.

1 Comment
2024/04/22
16:58 UTC

1

Making a game overlay

Hey guys I am fairly new to programming and have a pretty basic understanding of c++. I am trying to make a basic overlay for games I am playing. This overlay would screenshot the specific screen coordinates of where it shows my currently playing spotify song, then relaying that screenshot to the overlay. This would have to work in full screen games/programs. I haven’t started to write it yet and frankly do not know where to start. Anything helps thanks in advance.

1 Comment
2024/04/22
16:50 UTC

0

Purpose of CS books?

Always have been kind of strange to me, why would someone go to conventional academic books to learn coding in the era of AI, YouTube, Google?

I understand some just enjoy the more traditional feeling of learning via this method but it seems unbelievably obtuse and cumbersome considering the other options.

16 Comments
2024/04/22
16:49 UTC

1

How to stretch an image without distorting or zooming in?

I’m creating a website for a friend and am trying to use one of the pictures they gave me to put under the navbar and if I use cover it zooms in way too much and if I use contain with no repeats it shows the entire image but only in a small spot under the navbar and I can’t get it to stretch. I’m just gonna assume the image needs to be resized? If so what is the ideal size?

1 Comment
2024/04/22
16:47 UTC

1

C# PLAYER’S GUIDE

To people who bought the book, was the book useful?

1 Comment
2024/04/22
16:45 UTC

2

Fear of failure

Hello, how do I deal with the fear of failure ? It just makes me overthink so much that maybe I'm gonna put the work for nothing, that maybe I am not smart enough and in the end I'm not gonna be able to get a job. I just stay overthinking instead of actually coding. If I am doing a course I am going into it with the fear that I am not smart enough. How do I stop overthinking and just put in the work ?

9 Comments
2024/04/22
16:21 UTC

1

How to avoid a change in one place breaking something else?

Hello, ever since I started programming I've struggled with something - oftentimes, when I make a change in one place in the code, it will break something somewhere else.

I am guessing that solutions would mostly be writing decoupled code and tests, but I was wondering if anyone has some more specific, actionable advice to avoid side effects when updating code?

Thank you very much!

8 Comments
2024/04/22
16:03 UTC

1

Looking for a flexible, online Coding Bootcamp

Hi all - I've searched the sub but have a bit of a more narrow request than most of the posts here. I have a very strong quantitative background and have worked in finance most of my life - I'm interested in learning programming A) just for the sake of developing new skills, and B) to build some of the technical abilities I would likely need if I were to start my own project / business within the next couple of years.

I am an investment banker and don't have any interest in recruiting for big tech dev jobs, etc., so don't really need any of the networking benefits so many of these bootcamps espouse. I'm just looking for a flexible, rigorous, online coding academy that can teach me some foundational skills, with cost being no concern. Does anyone here know of anything approximating what I'm looking for? I would be fine either joining a live 'cohort', or doing the training asynchronous, I just really want to find a program / bootcamp to follow to keep me honest and to ensure I'm learning the right skills.

Thank you -

1 Comment
2024/04/22
15:53 UTC

1

As a beginner, should I do python web development without JS?

I want to study robotics in Germany. In such a case, I'll of course need to strengthen my python skills. While studying, I'll also need to earn some money, which I am hoping to do through freelancing in programming. I am almost done learning CSS and I know python without any specialisation in any library. What should I do now? Should I learn JS after CSS, even though I only need to learn web development for some money during my student years, or should I learn further web development through python, which will strengthen my command in the language and also provide me with a way to earn some money? I am very unsure of the latter option, but also confused as to how I'll be able to maintain my fluency in both the languages at the same time. Please advice me (I am currently in grade 11th, studying Physics, Chemistry, Maths and German at an Indian school, so the academic pressure is high as well.)

17 Comments
2024/04/22
15:40 UTC

1

Loops with switch

Hello guys im doing a very smal project for my school where i need to program a calculator in java. I wanted to use the switch statement to select the kind of equation u want to calculate but after i receive my answer, i don't know how to go back to the question of what kind of equation to use. Do you guys have solutions? (I'm still new to programming)

3 Comments
2024/04/22
15:19 UTC

1

APUE in MacOS

Hi, I have a Mac M1 and I want to read the book Advanced programming in the UNIX environment. Can I do the exercises there on a Mac computer?

2 Comments
2024/04/22
15:08 UTC

0

Is this how I fail fizzbuzz?

I'm working my way through online C++ training, and came across fizzbuzz. I did it 3 different ways, including with *if else* and both *for* and *while* loops, and then a cheeky version with nested ternaries. I know this is "frowned upon" to nest them, but I can't help but love how concise it is, and is it really that shameful to use this with so few conditions? Here's my ternary version for reference. Any other recommendations for the surrounding code are appreciated!

#include <iostream>

using namespace std;

int Number {0};

void FizzBuzz() {

++Number;

Number % 15 == 0 ? cout << "Fizzbuzz":

Number % 5 == 0 ? cout << "Buzz":

Number % 3 == 0 ? cout << "Fizz":

cout << Number << endl;

}

int main() {

int i {0};

for (i = 0; i < 100; ++i) {

FizzBuzz();

}

}

36 Comments
2024/04/22
14:36 UTC

1

How do I code this

I want to code something that will search a file for a certain character that given by the user. Her is my current code but I don't know how to do it and this code doesn't even run.

import Isaac
def search(filename, keyword):
count = 0
with open(Isaac, Isaac) as file:
for line in file:
if keyword in line:
count = count+1
else:
print(count)
filename = "Isaac.py"
keyword = "Isaac"
input("Give a character or word: ")
search(filename, keyword)

Also here is a link to the replit I am programming this on

https://replit.com/@ahartness2228/IssacFinal#main.py

14 Comments
2024/04/22
14:30 UTC

0

Im learning my first programming language C++ ( i need tips)

Soo first of all why im using c++, its because im learning it at school and have no choice. SOOO i want some tips and maybe like a roadmap how should i learn how do i progress. What do i know from c++ ? so have build um calculator but in terminal and some similar projects'. and i have question, can you build like umm a app, or a software with c++

3 Comments
2024/04/22
13:59 UTC

0

I want to make an web to work with the object detection

the system will be like that the first page you will be able to open the camera after you open it object detection will be working and detection object/items then add it to the second page which is shopping cart then you will have 2 buttons named (cash, card payment) if you pay by card you will be scanning a qr code if you pay cash the receipt be printed

I have the code and object detection model which I found them online I have no clue how to manage and create a website like that or to connect my edge impulse model to the code it seems like nothing working can someone please help me with this it’s urgent

1 Comment
2024/04/22
13:25 UTC

8

Question about Python

Submitted a final project for class and I used a “name” = “__main” function to define a main menu for a text based game.

Professor took points off because she “would’ve liked me to define a new variable called main_menu()” instead of just using the main function.

So my question is: in a real job does it really matter 😅😂

21 Comments
2024/04/22
13:14 UTC

0

How to create a deep learning model to predict demand in taxis?

I have a processed data set containing the time, date and location for pickups and drop off for taxi journeys . however i am unsure what to do next? I want to use a deep learning model, but what exactly do i predict?

4 Comments
2024/04/22
12:55 UTC

9

Best Practices to send for Empty Values of a JSON API?

What do you choose? Getting lots of conflicting answers.

  1. Null
  2. Undefined (Omitted from JSON)
  3. Empty of that type?
    1. String = ""
    2. Number = 0
    3. Boolean = false
    4. Array = []
    5. Object = {}

CMS JSON API to be consumed by JS Framework Frontend

12 Comments
2024/04/22
12:50 UTC

1

How do I get hands-on "work experience" on Typescript and Nest.js if my current work only uses Node.js and Express?

I am a software engineer, specifically more proficient in the JS syntax. My work mostly revolves around using Express to create backend services for the frontend team. Recently, I've tried to research other jobs online with similar job description, but a lot of them require working knowledge on TS or Nest instead of the usual MERN stack.

I have tried to attend courses online on both, but I often feel that they're not products that are shipped for production use, and as such feel less qualified than others who have shipped actual products using TS and Nest. How can I earn similar "work experience" in shipping actual products using TS and Nest? And is there any way not to be too involved in the FE work?

2 Comments
2024/04/22
12:13 UTC

0

JAVA STUDY BUDDY

I have recently started studying Java from Hyperskill, If anyone can guide me and be my mentor or if anyone wants to study with me ( Only if you are really passionate about it, because of the time constraints ) Do let me know.

3 Comments
2024/04/22
11:34 UTC

1

Abbreviated wheels in Python?

I want to create a Python script that is generating abbreviated wheels by giving as input n, k and t.

e.g.

input: n=4, k=3, t=2

desired output:

1, 2, 3
1, 2, 4
1, 3, 4

I have the following Python script that is supposing to do this but it seems that the output is not as expected:

from itertools import combinations

def generate_lottery_wheels(n, k, t):
    """
    Generate lottery abbreviated wheels.
    
    Parameters:
    n (int): Total number of lottery numbers.
    k (int): Size of the lottery ticket.
    t (int): Guarantee that the ticket has 't' winning numbers.
    
    Returns:
    list of tuples: List of all possible combinations.
    """
    # Generate all possible combinations of n numbers taken k at a time
    all_combinations = list(combinations(range(1, n+1), k))
    
    # Filter combinations to only include those with at least 't' winning numbers
    abbreviated_wheels = [combo for combo in all_combinations if sum(combo) >= t]
    
    return abbreviated_wheels

# Example usage:
n = int(input("Enter the total number of lottery numbers (n): "))
k = int(input("Enter the size of the lottery ticket (k): "))
t = int(input("Enter the guarantee that the ticket has 't' winning numbers: "))

wheels = generate_lottery_wheels(n, k, t)
print(f"Generated {len(wheels)} lottery wheels:")
for wheel in wheels:
    print(wheel)

And this is the output:

Enter the total number of lottery numbers (n): 4
Enter the size of the lottery ticket (k): 3
Enter the guarantee that the ticket has 't' winning numbers: 2
Generated 4 lottery wheels:
(1, 2, 3)
(1, 2, 4)
(1, 3, 4)
(2, 3, 4)

[Program finished]

As you can see the output is not so abbreviated.

How to do this in Python?

I tried to do it by logic but it seems that something is missing.

Thank you in advance!

2 Comments
2024/04/22
11:33 UTC

0

Feeling fear of loosing my job over mistake

Made a mistake that went to production Hi guys, I am Jr developer and it's my first project. It's been 3 months only, So there was requirement from client to change generation rule of one of the file. As I wasn't having access to required tools my senior made the changes with help of his senior. As there were 3 fields in total for creating condition, they messed it. I tested only four test combinations. I reviewed them in code review. Also QA missed it and also two dependent apk's QA also missed this condition. Before release I asked senior about this he said ignore it now. Also as we are working on same part so we are pushing correct condition now. I am not sure about what is impact gonna be and I am fearing that I will lose my job.

13 Comments
2024/04/22
10:53 UTC

7

Worth it books abt computer hardware or architecture?

Hi, just looking for books that are still relevant on computer hardware or architecture.

I also saw this very old reddit article discussing But How Do It Know? by J Clark Scott, is that too old to still be relevant or should I give it a read and anything else?

13 Comments
2024/04/22
10:32 UTC

1

404 Not Found Error when deploying flask web app to Vercel

Hi,

So, I was trying to learn how to build and deploy a really simple Hello World Flask web app to Vercel but after the deployment is done, I just get this -

404: NOT_FOUND

Code: NOT_FOUND

I've tried:

  1. Changing the Node.js version to 18.x (got this from one of the previously stack overflow answers)

  2. writing this in the vercel.json file -

    { "rewrites": [ { "source": "/(.*)", "destination": "/" } ], "version": 2, "builds": [ {"src": "./app.py", "use": "@vercel/python", "config":{"runtime":"python3.9"}} ] }

Please help me with this. I've tried searching online but none of the searches yielded any results for me. Or if you know other better ways to deploy a flask app preferably free then please let me know. Thank you

5 Comments
2024/04/22
10:28 UTC

1

Sources for ETL learning

Hey gang, so I've recently been moved into a data team where they want me to work on ETLs using python and scala through data bricks. The issue is that I've no knowledge in python, scala or ETLs. Whilst I've enrolled in a few python and scala courses I'm not seeing anything for ETLs. I'm really just looking for fundamentals on how an ETL should be approached, what needs to be considered etc. Does anyone have any sources on this? Thanks in advance.

1 Comment
2024/04/22
10:20 UTC

Back To Top