If you have
x = ['A', 'B', 'C']
y = ['D', 'E', 'F']
then you can calculate:
x+y # ['A', 'B', 'C', 'D', 'E', 'F']
But if you do
sum([x,y])
you get
TypeError: unsupported operand type(s) for +: 'int' and 'list'
Any idea why?
If you have
x = ['A', 'B', 'C']
y = ['D', 'E', 'F']
then you can calculate:
x+y # ['A', 'B', 'C', 'D', 'E', 'F']
But if you do
sum([x,y])
you get
TypeError: unsupported operand type(s) for +: 'int' and 'list'
Any idea why?
Its, because sum
allways 'adds' the start
element which defaults to 0
.
Try
sum([x,y], start=[])