# you should avoid names which are used for # bult-in function/classes # list is one of them data = [('aaastring', 245878L, 2475L, 'anotherstring'), ('bbbstring', 7894578L, 456897L, 'yetanother'), ('aaaform', 2445L, 325478L, 'dummy')] new_list = [] for row in data: # row is a tuple # a tuple is imuatble # you need to create a new one # or exchange the tuple with a list row = list(row) row[0] = 'Replacement for col0 of all rows' new_list.append(row)Content of new_list
Output:[['Replacement for col0 of all rows', 245878L, 2475L, 'anotherstring'],
['Replacement for col0 of all rows', 7894578L, 456897L, 'yetanother'],
['Replacement for col0 of all rows', 2445L, 325478L, 'dummy']]
Instead of overwriting the first column blindly, you can pass them into a function, which does the work for manipulation based on original data of the object in the first column.By the way, use Python 3. It gives you super powers.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!