Header MY

Coding Education

5 min read

What Is a String in Programming?

Hafiz Rahman

Hafiz Rahman

Lead Coding Instructor at Algonova Malaysia

What Is a String in Programming?

A string is a text data type in programming — a sequence of characters (letters, numbers, spaces, or symbols) written inside quotation marks, such as "Hello" or "Player123". Computers treat anything inside quotes as text to store or display, not as a number to do maths with.

Table of Contents

How a String Works

When you type a name, message, or label into a program, the computer stores it as a string, keeping each character in order — so "cat" is three characters: c, a, and t. In Scratch, the green join block glues two strings together: join "Hi, " with a player's name to build a friendly greeting. In Python, a young coder writes player_name = "Aisha" and then print("Welcome, " + player_name), and the screen shows Welcome, Aisha. Here is one useful fact: a string can hold digits too, but "25" in quotes is text, so the computer will not add it like the number 25 until the value is converted.

Examples of Strings

Common strings include a player's name like "Aisha", a greeting like "Well done!", a menu label like "Start Game", or a level tag like "Level 3". Even a phone number saved as "012-3456789" is a string, because it sits inside quotes and is not used for maths. A string can be a single character such as "A" or a whole sentence. Programmers sometimes call a string a text value, since it always holds readable text rather than a quantity.

String vs Number

The difference is simple: a string is text inside quotes, while a number is a value the computer can calculate with. Typing 5 + 3 gives 8, but "5" + "3" joins the text into "53". This is why a score kept as a number can go up when a player wins, while a name kept as a string stays exactly as written. Turning one into the other is a normal step young coders learn, using a block or function that converts "25" into the number 25 when a calculation is needed.

Why It Matters for Kids

Strings are how programs talk to people — every game-score label, chat message, and menu button is made from them. Learning to handle text early gives children a foundation for building interactive projects, and it supports the problem-solving and computational-thinking goals in Malaysia's KSSR and STEM curriculum. Children in Algonova coding classes use strings from their very first Scratch game to name characters and print messages on screen. Understanding strings pairs naturally with knowing what a variable is, because a string is usually stored inside a variable.

Curious? A free trial lesson lets your child build their first talking program.