Back to Course

Introduction to Python

0% Complete
0/0 Steps
  1. Python: Basics
    14Topics
    |
    15 Quizzes
  2. Python: Control Flow
    12Topics
    |
    12 Quizzes
  3. Python: Errors
    5Topics
    |
    5 Quizzes
Lesson 1, Topic 3
In Progress

Python: Strings

Yasin Cakal 3 Oct 2021
Lesson Progress
0% Complete

Strings are how computer programmers refer to blocks of text. We created the string "Hello world!" in our previous exercise. A string is surrounded by double quotes "Hello world" or single quotes 'Hello world' in Python. It makes no difference which type you use; the important thing is to be consistent. Here are some examples:

# The following print functions both display the same thing
print("Hello there!")
print('Hello there!')

So, what is the purpose of having both double quotes and single quotes? The answer is to display either double quotes or single quotes using the print function. Here are some examples:

Output:

The cat said 'meow'
The cow said "mooo"

%d bloggers like this: