How To Write A Nested Loop In Python