pythonified my solution of string1.py