Python

Loop over files in a directory

import os

directory = os.fsencode(directory_in_str)
    
for file in os.listdir(directory):
    filename = os.fsdecode(file)
    if filename.endswith(".txt"): 
        print("Found a text file"))
        continue
    else:
        continue

Virtual environments

Create virtual environment

python -m venv .venv

Activate virtual environment

source .venv/bin/activate

Deactivate virtual environment

deactivate

Check if string is valid positive integer

'14'.isdigit()

Test if elements of a list are in another list

any(map(lambda v: v in list2, list1))