NVIDIA interview question

flatten list to sum in python