Python 3 Script to Find the Sum of Array or List Using Built in Sum() Method in Python

Python 3 Script to Find the Sum of Array or List Using Built in Sum() Method in Python Full Tutorial For Beginners

Python 3 Script to Find the Sum of Array or List Using Built in Sum() Method in Python

# Python 3 code to find sum 
# of elements in given array 
# driver function 
arr = [] 

# input values to list 
arr = [12, 3, 4, 15] 

# sum() is an inbuilt function in python that adds 
# all the elements in list,set and tuples and returns 
# the value 
ans = sum(arr) 

# display sum 
print ('Sum of the array is ',ans) 

# This code is contributed by Dhananjay Patil
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment