Pattern Problem Using Python