teach-ict.com logo

THE education site for computer science and ICT

3. String data type

Strings let you store more than one character in a variable.

They are called strings because you 'string' the characters together, into a word, a sentence, or entire paragraphs.

You can even store numbers as strings, as long as you are not planning on performing any maths on it. Telephone numbers, for example, are often stored as strings.

Examples that use string
Item Description
Name Harry Potter
Address 29 Craft Avenue
Telephone number 022984848
Car Registration number CX45 829
Colours Blue

Strings can be any length, and still be stored in a single variable.

String data is often indicated by surrounding it with either speech marks or quotation marks, like this:

"29 Craft Avenue"

This is a line of code in Python to assign a string value

              MyString = "This string has 6 words in it"

In theory you could store every single letter as a character data type, but it is much more useful to treat the whole sentence as one string called 'MyString'.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: String data type