Strings and lists
Working with sequences of characters and sequences of values, and how Python's references behave.
About 8 hours of study
Learning objectives
- Index, slice and search text
- Store and change values in lists
- Loop neatly with enumerate and zip
- Work with tables stored as lists of lists
Lessons
- 1
Working with strings
Index, slice and loop over text, and use string methods such as upper() and replace().
- 2
Lists
Store many values in one list, change it, loop over it, and see why two names can share one list.
- 3
enumerate and zip
Loop with a counter using enumerate, and walk through two lists side by side with zip.
- 4
Lists of lists
Store tables and game boards as nested lists, and avoid the trap of copying a row.
Module practice
- Count the vowelsEasy
- PalindromeMedium
- Run-length encodingHard
- Largest and smallestEasy
- Second largestMedium
- The longest rising runHard
- Numbered mark listEasy
- Sum of productsMedium
- Above or below the averageHard
- Row sumsEasy
- Swap rows and columnsMedium
- Who won at noughts and crosses?Hard