Regex newbie in Python


This is the first time i am using regex  and i am having trouble with an exercise. It may be very simple, and i am probably doing something very wrong but i can t figure out what.

I am supposed to check the format of mail adresses, following some rules:

-it has to begin with 1 to 4 letters between a and p

-then 0 to 5 numbers between 0 and 9


I am trying to check if a mail adress is respecting those rules. I wrote:


It does not work all th time. Is that a good approach? Is there a better way to do it?

Thank you very much in advance for your help and understanding