Adds a counter in Scala, updates Python code to be a bit more functional, and conform to PEP standard.