Python Datatype - Strings

Strings: The Textual Heart of Python In Python, strings are sequences of characters used to represent text. You can think of them as an ordered collection of letters, numbers, symbols, and spaces. To define a string, you enclose your text within: Single quotes, double quotes Python is flexible with strings. You can enclose them in eithers in single quotes ’ or double quotes ". s1 = 'Hello world' # Single quotes s2 = "Hello world" # Double quotes The key is to be consistent, but there are times you’ll want to include one type of quote within a string enclosed by the other type.
2 minutes to read