Nested Loop In Python Pattern