Python version of networks assignment