What is a string?
In short
A string is a piece of text in a program: letters, digits, spaces and symbols in a row, written between quotes.
Programs work with text all the time: names, messages, passwords, whole files. In code, a piece of text is called a string, because it's a string of characters one after another. The quotes show where the text starts and ends, so the computer doesn't confuse it with the code around it.
Strings come with tools for everyday jobs, like changing them to capital letters, finding a word or joining two pieces of text together.
Python
Join strings and change them
name = "Ada"
greeting = "Hello, " + name
print(greeting)
print(greeting.upper())
print(len(name))Output
Hello, Ada
HELLO, ADA
3JavaScript
The same idea in JavaScript
const name = "Ada";
const greeting = `Hello, ${name}`;
console.log(greeting);
console.log(greeting.toUpperCase());
console.log(name.length);Output
Hello, Ada
HELLO, ADA
3Learn it properly
These free lessons teach it step by step, with questions and a program you write yourself.
- Joining and Formatting TextLearn Python →
- Slicing and String MethodsLearn Python →
- Template LiteralsLearn JavaScript →
Try your first lesson free
Codiqo teaches coding in five-minute lessons with real code. Free on the web, iPhone and Android.