Exercises
Lists
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
Make a list of the three names Ada, Grace and Katherine, then print how many there are.
Python
# build the list and print its length
Square brackets, commas between items, then len().
names = ["Ada", "Grace", "Katherine"]
print(len(names))Exercise 2Passed
Turn the string abc into a list of its characters and print it.
Python
# print ['a', 'b', 'c']
list() turns any sequence into a list.
print(list("abc"))Exercise 3Passed
Print how many times 10 appears in the list.
Python
scores = [10, 20, 10, 30, 10]
# print the count of 10
Lists have a count method.
scores = [10, 20, 10, 30, 10]
print(scores.count(10))