I have a 2D list that looks like this:
table = [[\'donkey\', \'2\', \'1\', \'0\'], [\'goat\', \'5\', \'3\', \'2\']]
I want to change the la
I like Shekhar answer a lot.
As a general rule, when writing Python code, if you find yourself writing for i in range(len(somelist)), you're doing it wrong:
enumerate if you have a single listzip or itertools.izip if you have 2 or more lists you want to iterate on in parallelIn your case, the first column is different so you cannot elegantly use enumerate:
for row in table:
for i, val in enumerate(row):
if i == 0: continue
row[i] = int(val)