solve PE4 and PE5.py