From Pseudo Code to Robust Programs: Syntax vs Logic Errors

Hello everyone~

In the previous session, we created a very simple program using something called pseudo code. The logic was as follows: if the current time is 19:00 (7 PM), display “I love you ❤️,” otherwise, display “I like you ❤️.”

now = datetime.now() → check the current time

if now.hour == 19: → if the current hour is 19...

print("I love you ❤️") → display “I love you ❤️” on the screen

else: → otherwise...

print("I like you ❤️") → display “I like you ❤️”

This logic is simple, but it’s a great example of the basic structure of coding. We set a condition and defined what happens depending on that condition.

However… there are always variables in the real world. No matter how perfect we think our logic is, when we actually run the code, there will always be unexpected situations.

When we write code, we encounter many types of errors. Aside from environment configuration issues, errors can generally be divided into two main categories:

  1. Syntax Errors
  2. Logic Errors
Editor showing error underline for a misspelled function

For example, if you accidentally typed Srint instead of print, the editor would underline it and show a message.

Syntax errors are simple mistakes like missing parentheses or misspellings — and most development tools automatically catch them.

But logic errors are different.

These are cases where the syntax is correct, but the program doesn’t produce the result we intended. In other words, if the program runs fine but shows the wrong result — that’s a logic error.

No matter how advanced technology becomes, this is an area that still requires human reasoning. AI tools like ChatGPT can analyze logical errors to some degree, but no matter how accurately they identify them, understanding why the problem occurred and fixing it is always up to us.

Coding isn’t just about writing grammatically correct code — it’s about designing the order of thought.


Now let’s go back and look at the code we made earlier and think logically about what could go wrong.

1. What if there’s no clock to check the time?

→ That means the attempt to check time fails altogether.

2. What if the time is incorrect?

→ For example, if the computer’s system clock is set wrong.

3. Which country’s 19:00 are we talking about?

→ Korea, the U.S., and Europe all have different time zones.

If even one of these situations occurs, our desired output — “I love you ❤️” at 19:00 — may not appear correctly.


Romantic dinner scene representing timed event

Let’s imagine a scene.

Suppose you’ve prepared a surprise event for someone you love.

A couple is sitting in a restaurant, enjoying dinner together. At exactly 7:00 PM, your program is supposed to automatically display the message “I love you ❤️” on the screen.

The lighting softens, the background music plays gently, and the atmosphere is perfect.

But then — 7:00 arrives, and nothing happens. Your partner tilts their head and asks:

“Huh…? What were you trying to do?” 😅

You hurriedly look at your watch — only to realize the clock was set 10 minutes fast. That tiny error ruined the perfect moment.


A small logical mistake like this can ruin even the most important event. This isn’t just a funny story — it’s a lesson that every coder should take seriously.

The logical completeness of a program is directly tied to the trustworthiness of its outcome. Just like how poor preparation can ruin a plan in daily life, a program without full consideration of all possible variables will go off track. (Indeed, many real-world bugs occur simply because clocks weren’t synchronized properly!)


Now, let’s think about how to handle these problems.

Case 1: The clock can’t be accessed

If the program fails to find the clock, it can’t check the time — so nothing else can proceed. In this case, we use exception handling to display a message like:

“Unable to check the time because the clock cannot be found.”

This tells the user immediately that an error has occurred and prevents the program from crashing.


Case 2: The time is wrong

Before using the time value, the program should compare it to a standard time (for example, the server time). If they don’t match, the program should say:

“The time is incorrect. Unable to display the message.”

Running based on wrong data is like setting your alarm using a broken watch.


Case 3: Time Zone (Timezone) problem

To fix this, the code should explicitly state that it’s based on Korea Standard Time (KST). Otherwise, the program may work according to a different country’s time. For example, 19:00 in the U.S. is around 8–9 AM in Korea — meaning your romantic “I love you ❤️” might suddenly appear in the morning! 😅


Now, if we reorganize the improved logic step by step:

  1. Check the current time.

  2. If the time cannot be checked:
    → Display “Unable to check the time because the clock cannot be found.” and exit.

  3. If the current time differs from standard time:
    → Display “The time is incorrect. Unable to display the message.” and exit.

  4. If (Korean time) is 19:00:
    → Display “I love you ❤️”.

  5. Otherwise:
    → Display “I like you ❤️”.

It may look more complicated now, but the logical gaps are reduced. By filling these holes one by one, we make the program more stable and reliable — no matter what situation arises.


Here’s what the final code would look like in Python:

from datetime import datetime import pytz

try:
    tz = pytz.timezone('Asia/Seoul')       # Set timezone to Korea
    now = datetime.now(tz)                 # Get current time in Korea
except Exception as e:
    print("Unable to check the time because the clock cannot be found.")
else:
    # Compare with standard time
    if now.hour != datetime.now(tz).hour:
        print("The time is incorrect. Unable to display the message.")
    elif now.hour == 19:
        print("I love you ❤️")
    else:
        print("I like you ❤️")

You don’t need to fully understand the code itself — What’s important is the thinking process behind it.

This habit of checking and improving the logic step by step is what strengthens your problem-solving mindset.

When you run the program, you’ll see something like this:

Console output showing 'I like you ❤️' when it is not 19:00
Since it’s 4 PM now, “I like you ❤️” appears

The most important thing in coding is logical accuracy.

If you build something carelessly, your program will behave carelessly. Sometimes it might seem to work by chance, but eventually it’ll fail in an unexpected situation.

It’s just like life — if we live carelessly, we’ll eventually hit a wall somewhere. But if we plan carefully and think ahead, life flows much more smoothly. (…Honestly, I think I’ve been living too carelessly myself. 😅)


Especially for students, this kind of logical training is extremely valuable.

Coding isn’t just about learning technology — it’s about training your mind to think. Every single line of code contains reasoning and logic.

Once you develop the habit of questioning and verifying your logic, you’ll not only become better at coding, but also improve your ability to solve problems in all areas of study.


Today, we looked at why programs need to be logically safe, and why plugging logical holes in advance is so important.

Now, try using pseudo code to imagine different situations:

  • What if there’s no time?
  • What if the input is wrong?
  • What if the condition doesn’t match?

Write down how your program should respond in each case.

Practicing this way will naturally develop your coding intuition.


And remember — the most important thing is this sense. Being able to set up logic, consider exceptions, and understand what each line means — that’s the true starting point of programming and the essence of logical thinking.

With this mindset, you won’t just become a skilled developer — You’ll become someone who can solve problems and succeed in any field.


Next time, we’ll look at another key concept in programming — Variables.

Thank you so much for reading! Wish you all a happy day 😊

You can view the original blog post in Korean at the links below:

View in Korean