How To Write Nested Loop In Python