Implementing the porter stemmer algorithm with step by step instructions and comments in python 3 by reading http://facweb.cs.depaul.edu/mobasher/classes/CSC575/papers/porter-algorithm.html.
Note. NLTK has porterStemmer and you are adviced to use that.
from nltk.stem import PorterStemmer
stemmer = PorterStemmer()
stemmer.stem(word)