Questions
Mystery
modifying a list
letters = ["b", "l", "u", "e", "b", "i", "r", "d"]
for i in range(2, 7):
letters[i] = letters[i].upper()
print(letters)
Strings
a sequence of characters just like a list is a sequence of elements
Lists can contain anything, even a mix of different things, but strings only have characters
A character is a single letter, number, symbol, or blank
blanks: " " (space), "\t" (tab), "\n" (newline)
just like lists:
len returns the length
Can loop over characters with for
use in to check for containment
access individual characters with indexes
concatenate with +
unlike lists
fixed, cannot be modifed
immutable vs mutable, more detail next week
Python provides lots of useful operations
https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
Files (see
files.py
)
open
reading
writing
HW3 warmup