This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Strings [Oct. 18, 2012, 9:02 p.m.]



We will commonly be working with text data, or 'strings' in Python (and other languages). Strings are expressed using single ( ' ) or double (" ) quotes.

>>> 'This is a string of characters' # Single quotes
'This is a string of characters'
>>> "This is also a string of characters" # Double quotes
"This is also a string of characters"

Strings can be referred to by variables, for later usage.

>>> a_string = "I really enjoy working with strings."
>>>

Notice that when we assign the memory location of the string to a variable called 'a_string' the interpreter simply displays a new prompt. This differs from when we typed a string directly at the prompt, without a variable assignment.