pset6 of CS50x in Python