Image credit to @goumbik

Learn Programming with Python — Introduction to Data Types: Strings

Richard Quinn
The Startup
Published in
7 min readApr 30, 2020


Let’s explore the concept of data types and how Python represents text data as strings.

A Quick Review

In earlier instalments of this series we already came into hand-to-hand contact with different types of data:

  • String data was input from the console or output to the screen
  • Integer data was used to test different age conditions
  • Boolean data was used to control program flow

We also used Sets and Tuples to collect individual pieces of data into data structures. We won’t go deep into data structures in this instalment, but we will reuse the tuple and set structures we’ve already seen.

In this instalment we’re going to get our fingers typing Python code to illustrate how Python uses data types, specifically data types to work with text data.

Text Data Types in Python3

Text data, comprised of characters, is managed in Python as :

  • str data types contains a string of characters (even an empty sequence) such as Hello, World!

There are no other data types for textual data in Python. str is all you get, and is likely all you really need!

Here is some code which manipulates a String, using some of the built-in string functions. For a full list of these functions (known as methods), take a look at the official docs.

When I execute this code, I get the following:

But how does this work?

  • We defined a new variable named sentence in line #3 above. We assigned some text to this variable. Python automatically figured out that sentence contains a string of characters! Other programming languages make this much harder.



Richard Quinn
The Startup

I am a software engineering manager with over 25 years of experience. I am working to improve people’s health. Based in Basel, Switzerland.