A string is a way of representing text in Python. It could be a word, a sentence, or even a single character. Strings are always written inside quotes so Python knows it’s text and not code.
Examples:
print("Hello")
print('Good morning')
print("12345") # Even numbers in quotes are strings!
Notice that "12345" is different from the number 12345. The first one is a string (text), while the second one is a number (integer).
You can use either single quotes ('...') or double quotes ("...") to make a string. Both work the same — you just need to make sure the opening and closing quote match.
Try this
- Print your name using single quotes.
- Print your favourite food using double quotes.
- Try printing
"12345"(as a string) and then12345(as a number). Can you see the difference?
Printing strings
The print() function shows text on the screen. Think of it as a way of telling Python: “Display this for me.”
print("Welcome to Python!")
You can also print more than one piece of text at once by separating them with commas:
print("Hello", "world")
Python automatically adds spaces between the different items when you use commas.
Try this
- Print
"Python is fun"to the screen. - Print
"I love","pizza", and"chips"in one line using commas. - Try printing the same three words joined together without commas:
print("I love" "pizza" "chips"). What happens?
Joining strings (concatenation)
You can join strings together using the + symbol. This is called concatenation (joining).
Example:
first = "Hello"
second = "World"
print(first + " " + second)
This prints:
Hello World
Notice we added " " (a space inside quotes) to make sure the two words didn’t get squashed together.
You can join more than two strings together:
greeting = "Good" + " " + "morning" + "!"
print(greeting)
Try this
- Make two variables:
first_name = "Alice" last_name = "Smith" - Join them together to print your full name.
- Try adding a space between them.
Length of a string
Python can tell you how many characters are in a string using the built-in len() function. Characters include letters, numbers, spaces, and punctuation.
word = "Python"
print(len(word)) # 6
Each letter is counted, starting from the first P all the way to the last n.
Spaces and punctuation also count:
sentence = "Hello, world!"
print(len(sentence)) # 13
Try this
- Make a string with your favourite animal, e.g.
"elephant". - Use
len()to find out how many letters it has. - Try adding a space to the string, e.g.
"elephant animal". What happens to the length?
Accessing characters by position
Strings are like a row of characters in order. Each character has a position, called an index. In Python, the first position is 0, not 1.
Example with "Python":
P y t h o n
0 1 2 3 4 5
To get a character, use square brackets [ ] with its position:
word = "Python"
print(word[0]) # 'P' (first letter)
print(word[1]) # 'y'
print(word[5]) # 'n' (last letter)
If you try to use a position that doesn’t exist, Python will give an IndexError. For example, "Python" has 6 characters, so the highest index you can use is 5.
Try this
- Create
fruit = "apple". - Print the first letter.
- Print the last letter. (Hint: the last position is 4 because
"apple"has 5 letters.) - Try printing
fruit[10]. What error do you get?
Summary
- A string is text inside quotes.
- Use
print()to show strings on screen. - Join strings together with
+. - Use
len()to count characters. - Access letters by their position (starting at 0) with
[ ].
✅ With just these basics, you can already start writing small Python programs that work with text.










