How To Generate Pattern In Python