this post was submitted on 15 Jul 2026
21 points (95.7% liked)

Programming

27709 readers
474 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS
 

I'm a beginner in programming, and I found out I cannot even reproduce a simple number guessing program I have earlier copied from a book.

Is it a beginner issue, or there is more than just continuing to learn to be able to code without hints?

you are viewing a single comment's thread
view the rest of the comments
[–] hendrik@palaver.p3x.de 3 points 2 hours ago* (last edited 2 hours ago)

You'll get there. If you're struggling to remember what to do and in what order... I'd say keep things simple. Re-visit the needed concepts. In case of a number guessing game, that'll probably be conditions, loops, input and output, storing numbers. Make sure you understand each if those individually.

First, write a program which just echoes the input. You could write a separate program which just has two fixed numbers and compares them. You can then extend it to also read one of the numbers from user input. And you're half-way there.

Also make sure you can do those simple things half a day later, without the textbook opened.

I'd tackle the loops seperately (if that's contained in this example). Get comfortable with them. Start with a program that just counts from 0 to 99 and outputs all the numbers. You can then combine that with other concepts, like output "tomato" if a number is divisible by 6. Or if it's less than, greater than or equal something.
And if you don't get the loops... Just tell the user they have 10 tries and copy-paste your code ten times. That'll do it as well. And you can work your way up from there.

I think once you have a grasp of what all these things do, and you did a few super simple things with them on your own, it'll be more clear what to do with more complex things. In this case probably: loop. And inside of that loop, ask for a number, compare it to the secret number, and decide what to output on a condition. That's roughly an average number guessing game. I think you just need to tinker a bit more with each of the 5 concepts that get combined here.