Seminar 3: lists and reading from file

Hi, we'll start seminar 3 by looking at the slides we skipped on Monday; on opening and reading files. We will go through how to save files and your python programs in the same folder, so they can interact. There are two useful functions that are not in the slides, please prepare by looking them up online and see how they work:

1: the function in works on lists to check if a value exists there. For instance like this: 

for name in list_of_names

checks if name exists in list_of_names

2: the function .strip() takes away blank spaces and lineshifts from a text, useful when we read a file that contains lineshifts at the end of each line. Like this

name.strip()

will retun name without any blanks before or after

Publisert 17. sep. 2025 14:36 - Sist endret 17. sep. 2025 14:36