Python syntax card

Syntax only. Choose your own variables, decisions, loops and function logic.
This card does not contain a solution to the programming check.

Open a text file and close it safely when the block ends:
    with open(filename, mode, encoding="utf-8") as handle:
        ...

Common file modes:
    "r"    read
    "w"    write; replace any existing contents
    "a"    append; keep existing contents and add at the end

Read text:
    handle.read()
    handle.readline()

Write a string:
    handle.write(text)

A newline inside a string:
    "\n"

Remove surrounding whitespace from text:
    text.strip()

Convert valid integer text to an integer:
    int(text)

Convert a value to text:
    str(value)

Add one item to a list:
    items.append(value)

Find the number of items:
    len(items)

Use a fresh practice folder. Do not open an input file in "w" mode.
