# Looping over nested lists

# nested loops (for loop inside a for loop)
for i in range(2): # this loops twice
    print('outer')
    for j in range(3): # this loops three times for every i
        print('inner')
        
# How many times will 'outer' print?
# 3
# How many times will 'inner' print?
# 6

L = [['a' ,'b'], ['c', 'd']]
for sublist in L:
    for letter in sublist:
        print(letter)
        
L2 = ['ab','cd']
for word in L2: # here we iterate over a list
    for letter in word: # here we iterate over a string
        print(letter)

L3 = [['ab','cd'], ['c', 'd']]
for sublist in L3: # here we iterate over a list
    for string in sublist: # here we iterate over a string
        print(string)
        
L4 = [['ab','cd'], ['c', 'd']]
for sublist in L4: # here we iterate over a list
    for string in sublist: # here we iterate over a string
        for letter in string:
            print(letter)
            
L5 = [['dog', 'parrot'], ['cat', 'mouse']]
for sublist in L5:
    if sublist[0] == 'cat':
        for pet in sublist:
            print(pet)
            