I loop through a list of lists and when I append the item to an array it adds each letter separately and not the word as a whole unless I remove the '[]'.. why is it occurs, just curious? Example:
Just curious to know why this behavior occurs
def printTable(lists):
for list in lists:
s = []
for item in list:
s += item
print(s)
print()
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
printTable(tableData)
instead of adding each item to the list, it adds each letter (while removing the list data type it adds them by letters as excepted) just curious why is that happens.