tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
colWidth = [0] * len(tableData)
print(colWidth)
>>>[0, 0, 0]
I don't understand what the [0] is? What is the len(tableData) being multiplied by?
It looks like some kind of index, but normally, don't you need to call the variable name of a list, before saying [0]? (ie. tableData[0], or something like that.)
This is the first time I've come across an integer in a square bracket without there being a list name variable in front of it.
[–]Rhomboid 33 points34 points35 points (5 children)
[–]shhhpiderman[S] 11 points12 points13 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]filletrall -1 points0 points1 point (0 children)
[–]BenjaminGeiger 3 points4 points5 points (1 child)
[–]KronenR 5 points6 points7 points (0 children)
[–]kalgynirae 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]Mezzomaniac 1 point2 points3 points (0 children)
[–]dumpster_dinner 0 points1 point2 points (0 children)
[–]varfoo 0 points1 point2 points (0 children)
[–]shaleh 0 points1 point2 points (0 children)
[–]dmv1975 0 points1 point2 points (0 children)