Menu
Coddy logo textTech

String

Part of the Fundamentals section of Coddy's Python journey — lesson 5 of 77.

A character is a single letter, digit, or symbol (for example: 1, 6, %, b, p, ., T, etc.). Python has no separate char type — a single character is simply a string of length 1.

The str (string) type is a sequence of one or more characters.

To initialize a string value in a variable, enclose it within single or double quotation marks:

s1 = 'This is a string'
s2 = "This is also a string"

In the above example, two string variables are initialized, named s1 and s2

challenge icon

Challenge

Beginner

Store the string I am learning to code with Coddy! in a variable named coddy.

Be sure to store the exact string value with correct casing.

Cheat sheet

A char is a single character (e.g., 1, 6, %, b, p, ., T).

A str (string) is a sequence of multiple characters.

To create a string variable, enclose the text in single or double quotes:

s1 = 'This is a string'
s2 = "This is also a string"

Both single and double quotes are valid for creating strings in Python.

Try it yourself

# Type your code below
coddy = ?

# Don't change the line below
print(f'coddy = "{coddy}"')
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals