Q:

Python don't modify values while iterating over a list with zip(), but does it while with enumerate()

Why Python works differently when iterating using index numbers? For example with the zip function (that don't has indexes when used in the for loop) a value isn't stored in a variable. While with the enumerate() function (that allow me to have an "index" in the foor loop)  it happens normally. 
A solution that don't use index has different values for my "width" variable when I'm trying to print it inside and outside the loop, here the zip() function was used to work with the two lists at the same time without needing to deal with their indexes:
tableData = [['apples', 'oranges', 'cherries', 'banana'],
            ['Alice', 'Bob', 'Carol', 'David'],
            ['dogs', 'cats', 'moose', 'goose']]

def printTable(myListOfLists):
    colWidths = [0] * len(myListOfLists)
    for lists, width in zip(myListOfLists, colWidths):
        for item in lists:
            if width < len(item):
                width = len(item)
        print(width) #This prints my 'width' rightly
    print(colWidths) #This prints my 'width' wrongly

printTable(tableData)

The above code produces the following not desired output:
8
5
5
[0, 0, 0]

But if I use enumerate() (generating indexes to work with the two lists at the same time) the values modified inside my for loop will be properly saved in the width variable, see the code example:
tableData = [['apples', 'oranges', 'cherries', 'banana'],
            ['Alice', 'Bob', 'Carol', 'David'],
            ['dogs', 'cats', 'moose', 'goose']]

def printTable(myListOfLists):
    colWidths = [0] * len(myListOfLists)
    for index, lists in enumerate(myListOfLists):
        for item in lists:
            if colWidths[index] < len(item):
                colWidths[index] = len(item)
        print(colWidths[index]) #This prints my 'width' rightly
    print(colWidths) #This ALSO prints my 'width' rightly

printTable(tableData)

This second output is:
8
5
5
[8, 5, 5]

Then, please, how can I work with the zip() and have my "external" variable modified? What am I doing wrong? Thanks.

A:

by this way you wont change the value of the list you need the index to change the real value. 
example:
for e in [1, 2, 3]:
    e = 10  # this way is wrong 

data = [1, 2, 3]
for index, e in enumerate(data):
    e[index] = 50 # always it is needed an index  

a good way to solve your problem:
tableData = [['apples', 'oranges', 'cherries', 'banana'],
             ['Alice', 'Bob', 'Carol', 'David'],
             ['dogs', 'cats', 'moose', 'goose']]

data = [len(max(e, key=len)) for e in tableData]

print(data)

or 
tableData = [['apples', 'oranges', 'cherries', 'banana'],
            ['Alice', 'Bob', 'Carol', 'David'],
            ['dogs', 'cats', 'moose', 'goose']]

def printTable(myListOfLists):
    colWidths = [0] * len(myListOfLists)
    for index, row in enumerate(myListOfLists):
        colWidths[index] = len(max(row, key=len))
    print(colWidths)

printTable(tableData)

on another hand you could try out.
for i, (a, b) in enumerate(zip(alist, blist)):
    print i, a, b

