Lecture 2: Strings and Lists
Autumn 2026
1
Sli.do
#cse163
Questions?
Icebreaker
Watch any good movies or shows recently?
CSE 163
CSE 163: Strings and Lists
Announcements
2
CSE 163: Strings and Lists
Today’s Roadmap
3
CSE 163: Strings and Lists
Reminder: Course Website
4
CSE 163: Strings and Lists
Anatomy of a Function
5
def function_name(parameter, ...):
#Function code
return value
def keyword
Function name
Optional
parameters
Function code
colon
Indentation
Return statement
CSE 163: Strings and Lists
Strings and Lists
6
CSE 163: Strings and Lists
Strings and Lists!
7
CSE 163: Strings and Lists
Type/Structure Methods vs. Built-in Functions
8
s = "oN yOuR lEfT!"
print(s.upper()) #.upper() for strings
print(s.lower()) #.lower() for strings
s = "oN yOuR lEfT!"
c = ["blue", "green", "red", "yellow"]
print(len(s)) # len works for strings!
print(len(c)) # len works for lists!
CSE 163: Strings and Lists
Type/Structure Methods vs. Built-in Functions
9
s.method(optional,...))
function(s)
Can you think of any other built-in functions?
CSE 163: Strings and Lists
10
s = 'on your left!'
# Length
len(s) # 13
# Indexing
s[1] # 'n'
s[len(s) - 1] # '!'
# Looping
for i in range(len(s)):
print(s[i])
for c in s:
print(c)
l = ['blue', 'red', 'green']
# Length
len(l) # 3
# Indexing
l[1] # 'red'
l[len(l) - 1] # 'green'
# Looping
for i in range(len(l)):
print(l[i])
for word in l:
print(word)
CSE 163: Strings and Lists
Practice Problems!
11
CSE 163: Strings and Lists