Python sum() function with list parameter

前端 未结 3 770
栀梦
栀梦 2021-01-01 19:26

I am required to use the sum() function in order to sum the values in a list. Please note that this is DISTINCT from using a for loop to add the nu

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 20:14

    In the last answer, you don't need to make a list from numbers; it is already a list:

    numbers = [1, 2, 3]
    numsum = sum(numbers)
    print(numsum)
    

提交回复
热议问题