Make matrix exercise compatible with Python3