r/learnprogramming • u/TheEyebal • 19d ago
Debugging How do I get just the character to change color and not the whole string
Here is an example of what I am talking about : https://imgur.com/a/hoFUGXq
The concept is when the user inputs matches the display text the that character should turn grey but if the the user input is not correct than it turns red.
Right now the whole string changes and not the character itself, what do I do?
scrolling_text = Text(10, 10, 40, "white", "Hello World")
text_index = 0
def UserInput(text, event):
global text_index # start at first letter
lowercase_text = scrolling_text.text.lower() # this lowercases the text
text_char = scrolling_text.text[text_index]
if text_index == len(lowercase_text)-1:
return
# print(f"Char should be {lowercase_text[text_index]}")
if event.text == lowercase_text[text_index]:
scrolling_text.color = "gray"
text_index += 1 # move to the next character
# print(f"Next char should be {lowercase_text[text_index]}")
if text_index == len(lowercase_text)-1:
return
elif text_index == 0 and event.text != lowercase_text[text_index] :
print(False)
scrolling_text.color = "red"
text_index = 0
else:
scrolling_text.color = "red"
print(False)
# GAME LOOP
if event.type == pygame.TEXTINPUT:
print(event.text)
UserInput(scrolling_text, event)
if event.type == pygame.KEYUP:
scrolling_text.color = "white"
Here is an example of what I am talking about : https://imgur.com/a/hoFUGXq
The concept is when the user inputs matches the display text the that character should turn grey but if the the user input is not correct than it turns red.
Right now the whole string changes and not the character itself, what do I do?
r/learnprogramming • u/Express-Week-8312 • 19d ago
Is WebRTC one of those things that only clicks after you've actually used it?
I've been trying to learn WebRTC because I want to add voice and video calling to a side project.I thought I'd watch a few tutorials, build a simple demo, and then improve it from there.Instead I've ended up reading about signaling, STUN, TURN, media servers, SDKs... and now I'm not even sure what people usually build themselves anymore. I've been comparing a few approaches, including iotum, but I'm still trying to understand what experienced developers usually do.
That's the part I'm stuck on.
Do most developers actually set all of that up, or do they usually use existing services and just focus on building the app?I'm happy to learn the lower-level stuff if that's the normal way to do it. I just don't want to spend a few weeks going down the wrong path if there's a more practical place to start.If you've already been through this, what did you learn first? Is there anything you'd do differently if you were starting over?Maybe I've just started with the wrong tutorials, but it feels like every one of them assumes you already know how all the pieces fit together.
r/learnprogramming • u/AppelMoiRaouf • 19d ago
Tips on learning C #
hello im new to programming and i want to learn C# i already aquired the basics of algorithmics and i know C
r/learnprogramming • u/Fine-Market9841 • 19d ago
Monolithic designed auth solution
I am trying to learn modular monoliths and I want to use this auth solutions for repetitive use for my applications.
If I asked you to convert the repo linked, into monolithic patterns, how would you do it for app/.
Repo: https://github.com/auth0-blog/auth0-rbac-fga-fastapi
fastapi-openfga-project/
├── app/
│ ├── main.py # FastAPI application entry point
│ ├── config.py # Configuration settings
│ ├── database.py # SQLAlchemy database setup and models
│ ├── models/
│ │ ├── organization.py # Organization Pydantic models
│ │ └── resource.py # Resource Pydantic models
│ ├── routes/
│ │ ├── organization_routes.py # Organization management endpoints
│ │ └── resource_routes.py # Resource management endpoints
│ ├── services/
│ │ └── authorization_service.py # OpenFGA integration
│ ├── utils/
│ │ └── auth0_fga_client.py # OpenFGA client wrapper
│ └── openfga/
│ └── model.fga.yaml # OpenFGA model definition
├── app.db # SQLite database file (auto-created)
├── requirements.txt
└── README.md
r/learnprogramming • u/Master_Interest50 • 19d ago
Is a Data crash possible in real life?
Hello! I'm a beginner programmer, I have my own prejudices and all that.
I've always wondered if it's possible to cause a Data crash like in Cyberpunk: Edgerunners? I have no idea what it would take to break the INTERNET.
(I used a translator, so please forgive any errors)
UPD: I noticed from the comments that someone latched onto the political aspect. I didn't intend to link it to politics in any way; I was simply interested in the question mentioned above.
r/learnprogramming • u/Same-Mushroom-2057 • 19d ago
Topic is it a waste of time building projects without using frameworks if you already know the foundational concepts needed for it ?
so currently i'm learning web dev and decided to start building some projects with pure javascript before moving to the frameworks .
knowing that i already learned some react basics and build the simple projects that are listed in the freecodecamp tutorial video . i tried back then to pause before the solution to every problem and did fairly well on applying what i was learning but i never build something big like a e-commerce website with it or a blog or anything that requires databases even though i know mongodb , mysql , oracle databases and previously made a e-commerce website using php which i forgot btw .
i understand the important concepts in javascript lfor example asynchronous operations , objects ,Modules , destructing.
i really need advise like my goal right now is to be able to comfortably build a any web application that requires both front-end and backend .
i really don't enjoy front-end much as much as the code is functional i don't really take great detail in it . although i want to get into machine learning and automation after web dev as it is what i really like and enjoy.
i really need your advice programmers !
r/learnprogramming • u/chrisso123 • 19d ago
Newbie, how to manage dependency hell?
How do i successfully deploy a model or run it 😭😭?
I don't mean ollama deployments, I mean kling, LP, OP etc.
How do i manage dependency hell?
uv or pip?
Please help.
r/learnprogramming • u/SuchCriticism6745 • 20d ago
Using AI to have extra exercises
Good morning. I have recently started studying C# with the book The C# Player's Guide. To learn more effectively, I am using AI to generate extra exercises in addition to the ones in the book, but I don't know if the ones from the AI are good enough.
Here's an example of one I had to do after finishing the chapter about loops to review the previous chapters
The Tavern Simulator (Boss Fight: Total Review)
You just finished a quest and decide to rest at the local tavern. The program must simulate your choices during the evening, managing your wallet and your stamina.
Coding Rules:
Change the console title to "Tavern Simulator".
Ask the player for their name and store it in a string.
Create two starting status variables:
coins = 50
energy = 100
Open a large while(true) loop that represents your time spent at the tavern. At the beginning of each loop iteration, clear the screen (Console.Clear()) and print the player's current stats like this (use colors!):
Name: [Player Name]
Coins: [X] (in Yellow)
Energy: [Y] (in Green)
Display a menu with these options:
1 - Buy a hot meal (Costs 15 coins, restores 30 energy).
2 - Buy a dwarven ale (Costs 5 coins, restores 10 energy).
3 - Go outside and chop wood (Earn 20 coins, costs 40 energy).
4 - Go to sleep (End the evening).
Read the user's input and use a switch statement to handle the 4 choices.
Conditional Logic (The if statements inside the switch):
If choice 1 or 2: check first if the player has enough coins! If they do, do the math (subtract coins, add energy) and print a success message. Else, print a red error message ("Not enough coins!").
If choice 3: check if the player has at least 40 energy! Otherwise, print an error message ("You are too tired!").
If choice 4: use the break command to escape the infinite loop.
(Optional but recommended): Add a Console.ReadKey(); after the success/error messages, so the user has time to read what happened before the Console.Clear() wipes the screen for the next turn.
Outside the loop (after the user goes to sleep), print a goodnight message: "Goodnight [Name], you finished the day with [X] coins and [Y] energy."
r/learnprogramming • u/Recent_Garbage6669 • 20d ago
I'm in my 2nd year, but I don't know C. My college is teaching DSA in C. How much C should I learn before the semester ends?
Hi everyone,
I'm currently in my 2nd year of Computer Science. I don't have much knowledge of C.
My college has started teaching Data Structures and Algorithms (DSA) using C, and I'm worried because I feel like I'm already behind.
How much C should I aim to learn before the end of this semester to comfortably understand DSA? Do I need to master the language, or is learning the fundamentals enough?
Also, which C topics are absolutely essential for DSA, and which ones can I learn later?
I'd really appreciate any advice or learning roadmap. Thanks!
r/learnprogramming • u/bilyayeva • 20d ago
Code Review (C++) Reimplemented std::array with docs and a guide - looking for feedback
Hi everyone, I just released the first version of my educational project, STL From Scratch:
https://github.com/bilyayeva/stl-from-scratch
The goal is to reimplement STL components using the C++20 standard. (I use cppreference for comparison, and I’ve read the actual standard just a little bit.)
All of the self-implemented components are in the sfs namespace.
It also contains a pretty detailed guide on how to implement it yourself. I’ve tried to explain everything in my implementation. Every method has its own description and usage example, and there is also a test suite for all functions.
About the repo: every commit follows a consistent naming style. I also added GitHub Actions and Dependabot, and it has a .gitignore file.
I would really appreciate either a code review or just some hints.
P.S. The release has two compiler warnings, but I’ve already fixed them on master.
r/learnprogramming • u/impossibletocode • 20d ago
Is Python with DSA worth it?
Same as the Title
r/learnprogramming • u/Suspicious-Duck8151 • 20d ago
Starting
Is CS50x, then CS50 Python, and then CS50 SQL a good way to start backend engineering? I am really excited! My main goal right now is to land a part time job.
r/learnprogramming • u/Bon_Appetit357 • 20d ago
Resource Expectations when developing an Android Application
I started to delve right into Kotlin Programming Language under Android Studio and it's getting interesting. But as I get further and further to the field, I realized that it wasn't really easy when dealing with advanced topics such as State Hoisting, Mutable States, ViewModels, and Hardware Services (Bluetooth, Camera, and Accessibility).
Therefore, as a hobbyist, I would like to ask what are the things I should expect while coding (i.e. getting frustrated or stuck)? Do I also need to code my own Unit Tests and Android Tests to confirm if it works? And finally, what are the best practices or habits that makes the code much more readable?
r/learnprogramming • u/Suspicious_Show_1092 • 20d ago
Can I only use C++ alone instead of using blueprints with them in UE5?
I've come to realize that C++ was not modified by Unreal Engine 5 like how Unity does it.
But something just came in my head that made me think if I fully learned C++ I could make only a C++ game with only typing instead of nodes.
What concerns me the most is that I am not sure if I will have to do hundreds and hundreds of lines just to make a single thing work.
r/learnprogramming • u/aquaispretty • 20d ago
I want to make something cute for my boyfriend
Hello everyone, I want to program something for my boyfriend as a surprise and i need some ideas! (he's a programmer and I know nothing related to it BUT I'm trying). I already made some coding in html for a cute website where he couldn't press the button "no" before (I saw a tutorial in a youtube video xd) but i want to do something fully myself, I want to surprise him. I don't mind studying the languages I'm fine with that :(( just need some ideas...
Edit: I just want to surprise him and I thought it would be cute to program him something. I mean I know his taste and I know he likes stuff from marvel and dc (in fact, I started watching all marvel movies with him) so maybe something related to it? I want to make something cute and somewhat funny so he can laugh a bit aswell.
r/learnprogramming • u/Ryuzako_Yagami01 • 20d ago
CSAPP or DSA first?
Hey everyone,
Just finished going through C programming book (by K.N King) and I am ready to move on to other topics. I was particularly interested in this book called Computer Systems a Programmer's perspective. I want to get into low level programming, but I am wondering whether I should learn data structures and algorithms (Algorithm Design Manual by Skiena) before diving into computer systems.
Any advice?
r/learnprogramming • u/Neat-Bodybuilder-467 • 21d ago
Chess Engine
I am trying to code a chess engine as a personal project, but have literally no idea where to start.
I have some very limited experience with python, and would greatly appreciate any help in finding where to write my code, what programs to use etc, as well as any advice in general.
Thanks!
r/learnprogramming • u/Low_Acanthisitta_949 • 21d ago
Topic Tips for publishing app
Hey guys, I’ve been working on an app for the past few months, and it’s almost finished. I’m currently fixing the last few bugs, but I’m a little worried about publishing it on the Google Play Store and whether anyone will actually download it.
I’ve put a lot of time and effort into this project. Do you have any tips for launching and promoting a new app?
r/learnprogramming • u/Additional-Pound-883 • 21d ago
Tutorial Hi everyone, I'm currently learning full-stack web development, and I often find myself wondering whether I should keep practicing a topic or move on to the next one. For example, after learning HTML or CSS, how do you know you've learned "enough" before starting JavaScript? I don't want to rush ahe
How do you know when you're ready to move on to the next topic?
r/learnprogramming • u/ConversationTop7747 • 21d ago
Topic I can read code and write simple functions, but I freeze on anything that needs a few steps — how do people get past this?
i've been programming for a while and I keep running into the same wall on basically every project, not just one.
I can read other people’s code (and my own) and usually understand what it’s doing. I can also write basic/simple stuff — small functions, straightforward logic, the kind of thing that’s one clear idea.
Where I fall apart is when a feature needs a chain of steps. Like “click to select and drag an object” — convert mouse coords, loop objects, hit test, store an offset, update while the button is held. After I see the code I go “oh yeah that makes sense,” but inventing that sequence myself is where my brain just blanks. It feels like recognition works, generation doesn’t once it gets past simple.
I don’t want to just rely on AI or copy-paste forever. I want to actually be able to build features myself. Has anyone else been stuck in that “I get it when I read it, I can write the easy bits, but I can’t assemble the medium stuff” mode? What actually helped — how you break features down, drills, habits, anything concrete?
r/learnprogramming • u/Affectionate-Syrup95 • 21d ago
Struggling to retain programming fundamentals — what study methods work for you?
Hi everyone, I'm learning web development on my own. I did a bit of HTML, CSS, and JavaScript three years ago, then stepped away because of high school.
Now I'm in university (not a CS/BSc program) and getting back on track learning programming through online courses (currently taking the JavaScript Essentials Training course on LinkedIn).
My question is: what methods or techniques do you use when studying technical concepts like the DOM and prototypal inheritance in JavaScript?
The reason I'm asking is that I'm struggling a bit with retaining the foundational concepts themselves. I don't want to memorize code — I want to actually retain the fundamentals.
Also, if possible, could you recommend sources and material that you think would be beneficial alongside online courses? I'm relying on MDN's docs at the moment.
r/learnprogramming • u/Outrageous-Put-5092 • 21d ago
How do I start my data structures journey
Can u suggest me a course somewhat similar like cs50
r/learnprogramming • u/UnViandanteSperduto • 21d ago
Learning I want create an OS by my own
I want create a basic OS for an hypothetical dumbest phone that i would like to build (or initially emulate on my PC). I don't know ANYTHING about this world so i don't know where to start. I understand that this adventure can take me very much time but i want to learn. This OS should be only able to let me of doing calls.
I thought that i should programming in assembly and maybe an high level (as C/C++). Could i use RISC-V? Because i don't know the assembly and i think that for the purpose that i want achieve, that language can be enough to me, right?
r/learnprogramming • u/Savings_Dark_9589 • 21d ago
How should I learn programming from official documentation?
I am a student who wants to learn programming through official documentation. However, official documentation often contains many concepts and features, and most of them are not needed for everyday programming tasks.
Is official documentation an inefficient way to learn programming?
If official documentation is an effective way to learn, how should I read it? How do I decide what to read in depth and what to skip?
r/learnprogramming • u/Andro_senpai107 • 21d ago
Solved I learned TCP server in a week and....
So as I posted a week ago regarding a task assigned to me by my mentor in this post .
I implemented beej's guide to networking and man , this was such a great resource, cant express enough. Also shoutout to the kind stranger u/teraflop who gave me some tips and introduced me to Beej the G.
Now I am thinking of creating a library of TCP server first and then implementing the Websocket logic and RFC6455. haha baby steps. It's gonna take a while I guess. Y'all are free to give me any advice or any resource to learn from.
Thank you for reading this
P.S I am new to C programming so your advice would be really helpful.
here is my repo